From f2ed1a2c937aaa54d1cc98b00841943d48ce41ea Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Tue, 26 Mar 2024 18:31:47 -0600 Subject: qemu: Remove versions older then 8.1, no longer compatible Versions older then 8.1 are no longer compatible with the runqemu. Signed-off-by: Mark Hatle --- .../recipes-devtools/qemu/qemu-xen_7.1.inc | 33 - ...syntax-error-that-causes-FTBFS-in-some-co.patch | 40 - ...plugging-emulated-devices-skip-virtio-dev.patch | 51 - ...return-error-from-xen_create_ioreq_server.patch | 55 - ...-add-pseudo-RAM-region-for-grant-mappings.patch | 252 --- ...en-mapcache-move-xen-mapcache.c-to-hw-xen.patch | 88 - ...003-hw-i386-xen-rearrange-xen_hvm_init_pc.patch | 106 - ...-qemu_map_ram_ptr-use-qemu_ram_ptr_length.patch | 113 -- ...ove-x86-specific-fields-out-of-XenIOState.patch | 180 -- ..._ram_addr_from_mapcache-return-1-in-case-.patch | 49 - ...-add-MemoryRegion-map-and-unmap-callbacks.patch | 150 -- ...ate-arch_handle_ioreq-and-arch_xen_set_me.patch | 192 -- ...-map-and-unmap-callbacks-for-grant-region.patch | 255 --- ...e-common-functions-to-hw-xen-xen-hvm-comm.patch | 2094 -------------------- .../0007-xen-mapcache-Fix-build-on-Arm.patch | 37 - ...req-creation-on-ioreq-registration-failur.patch | 42 - ...n-xen-all-export-xenstore_record_dm_state.patch | 48 - .../0008-hw-arm-Add-grant-mapping.patch | 39 - ...n-hvm-enable-xen-hvm-common-build-for-ARM.patch | 43 - .../0010-hw-arm-introduce-xenpv-machine.patch | 230 --- ...-do-not-set-have_xen_pci_passthrough-for-.patch | 33 - ...n-arm-call-qemu_find_tpm_be-if-CONFIG_TPM.patch | 72 - ...3-arm-xenpv-fix-TPM-address-print-warning.patch | 27 - ...ate-virtio-mmio-devices-during-initializa.patch | 83 - ...tialize-RAM-and-add-hi-low-memory-regions.patch | 105 - ...-accel-xen-and-drop-extra-interface-openi.patch | 79 - .../qemu/qemu-xilinx_2023%.bbappend | 5 - .../recipes-devtools/qemu/qemu_7.1%.bbappend | 5 - 28 files changed, 4506 deletions(-) delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xen_7.1.inc delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen-pt-fix-syntax-error-that-causes-FTBFS-in-some-co.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen-when-unplugging-emulated-devices-skip-virtio-dev.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen_common-return-error-from-xen_create_ioreq_server.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0002-xen-add-pseudo-RAM-region-for-grant-mappings.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0002-xen-mapcache-move-xen-mapcache.c-to-hw-xen.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0003-hw-i386-xen-rearrange-xen_hvm_init_pc.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0003-softmmu-let-qemu_map_ram_ptr-use-qemu_ram_ptr_length.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0004-xen-hvm-move-x86-specific-fields-out-of-XenIOState.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0004-xen-let-xen_ram_addr_from_mapcache-return-1-in-case-.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0005-memory-add-MemoryRegion-map-and-unmap-callbacks.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0005-xen-hvm-create-arch_handle_ioreq-and-arch_xen_set_me.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0006-xen-add-map-and-unmap-callbacks-for-grant-region.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0006-xen-hvm-move-common-functions-to-hw-xen-xen-hvm-comm.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0007-xen-mapcache-Fix-build-on-Arm.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0007-xen-skip-ioreq-creation-on-ioreq-registration-failur.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0008-accel-xen-xen-all-export-xenstore_record_dm_state.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0008-hw-arm-Add-grant-mapping.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0009-xen-hvm-enable-xen-hvm-common-build-for-ARM.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0011-meson.build-do-not-set-have_xen_pci_passthrough-for-.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0012-xen-arm-call-qemu_find_tpm_be-if-CONFIG_TPM.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0013-arm-xenpv-fix-TPM-address-print-warning.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0014-xen_arm-Create-virtio-mmio-devices-during-initializa.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0016-xen_arm-Add-accel-xen-and-drop-extra-interface-openi.patch delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx_2023%.bbappend delete mode 100644 meta-xilinx-virtualization/recipes-devtools/qemu/qemu_7.1%.bbappend (limited to 'meta-xilinx-virtualization') diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xen_7.1.inc b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xen_7.1.inc deleted file mode 100644 index 1210a3de..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xen_7.1.inc +++ /dev/null @@ -1,33 +0,0 @@ -# Xen-4.17 specific changes are only applicable on the target -SRC_URI_XEN = "" -SRC_URI_XEN:class-target = " \ - file://0001-xen-pt-fix-syntax-error-that-causes-FTBFS-in-some-co.patch \ - file://0001-xen_common-return-error-from-xen_create_ioreq_server.patch \ - file://0002-xen-mapcache-move-xen-mapcache.c-to-hw-xen.patch \ - file://0003-hw-i386-xen-rearrange-xen_hvm_init_pc.patch \ - file://0004-xen-hvm-move-x86-specific-fields-out-of-XenIOState.patch \ - file://0005-xen-hvm-create-arch_handle_ioreq-and-arch_xen_set_me.patch \ - file://0006-xen-hvm-move-common-functions-to-hw-xen-xen-hvm-comm.patch \ - file://0007-xen-skip-ioreq-creation-on-ioreq-registration-failur.patch \ - file://0008-accel-xen-xen-all-export-xenstore_record_dm_state.patch \ - file://0009-xen-hvm-enable-xen-hvm-common-build-for-ARM.patch \ - file://0010-hw-arm-introduce-xenpv-machine.patch \ - file://0011-meson.build-do-not-set-have_xen_pci_passthrough-for-.patch \ - file://0012-xen-arm-call-qemu_find_tpm_be-if-CONFIG_TPM.patch \ - file://0013-arm-xenpv-fix-TPM-address-print-warning.patch \ - file://0014-xen_arm-Create-virtio-mmio-devices-during-initializa.patch \ - file://0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch \ - file://0016-xen_arm-Add-accel-xen-and-drop-extra-interface-openi.patch \ - file://0001-xen-when-unplugging-emulated-devices-skip-virtio-dev.patch \ - file://0002-xen-add-pseudo-RAM-region-for-grant-mappings.patch \ - file://0003-softmmu-let-qemu_map_ram_ptr-use-qemu_ram_ptr_length.patch \ - file://0004-xen-let-xen_ram_addr_from_mapcache-return-1-in-case-.patch \ - file://0005-memory-add-MemoryRegion-map-and-unmap-callbacks.patch \ - file://0006-xen-add-map-and-unmap-callbacks-for-grant-region.patch \ - file://0007-xen-mapcache-Fix-build-on-Arm.patch \ - file://0008-hw-arm-Add-grant-mapping.patch \ - " - -FILESEXTRAPATHS:prepend:class-target := "${THISDIR}/qemu-xilinx-7.1:" - -SRC_URI .= "${@bb.utils.contains('DISTRO_FEATURES', 'xen', '${SRC_URI_XEN}', '', d)}" diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen-pt-fix-syntax-error-that-causes-FTBFS-in-some-co.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen-pt-fix-syntax-error-that-causes-FTBFS-in-some-co.patch deleted file mode 100644 index 99eaeeaf..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen-pt-fix-syntax-error-that-causes-FTBFS-in-some-co.patch +++ /dev/null @@ -1,40 +0,0 @@ -From ba24456b93a205b728475d5f0880f3ec495e383a Mon Sep 17 00:00:00 2001 -From: Chuck Zmudzinski -Date: Mon, 31 Oct 2022 17:35:52 -0400 -Subject: [PATCH] xen/pt: fix syntax error that causes FTBFS in some - configurations -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -When Qemu is built with --enable-xen and --disable-xen-pci-passthrough -and the target os is linux, the build fails with: - -meson.build:3477:2: ERROR: File xen_pt_stub.c does not exist. - -Fixes: 582ea95f5f93 ("meson: convert hw/xen") - -Signed-off-by: Chuck Zmudzinski -Reviewed-by: Philippe Mathieu-Daudé -Message-Id: <5f1342a13c09af77b1a7b0aeaba5955bcea89731.1667242033.git.brchuckz@aol.com> -Signed-off-by: Laurent Vivier ---- - hw/xen/meson.build | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/hw/xen/meson.build b/hw/xen/meson.build -index 08dc1f6857..ae0ace3046 100644 ---- a/hw/xen/meson.build -+++ b/hw/xen/meson.build -@@ -18,7 +18,7 @@ if have_xen_pci_passthrough - 'xen_pt_msi.c', - )) - else -- xen_specific_ss.add('xen_pt_stub.c') -+ xen_specific_ss.add(files('xen_pt_stub.c')) - endif - - specific_ss.add_all(when: ['CONFIG_XEN', xen], if_true: xen_specific_ss) --- -2.17.0 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen-when-unplugging-emulated-devices-skip-virtio-dev.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen-when-unplugging-emulated-devices-skip-virtio-dev.patch deleted file mode 100644 index 71dfb3be..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen-when-unplugging-emulated-devices-skip-virtio-dev.patch +++ /dev/null @@ -1,51 +0,0 @@ -From e2b85efc82bc26a838f666c8282528ee38cf6377 Mon Sep 17 00:00:00 2001 -From: Juergen Gross -Date: Tue, 16 Mar 2021 14:00:33 +0100 -Subject: [PATCH 1/8] xen: when unplugging emulated devices skip virtio devices - -Virtio devices should never be unplugged at boot time, as they are -similar to pci passthrough devices. - -Signed-off-by: Juergen Gross -Acked-by: Stefano Stabellini ---- - hw/i386/xen/xen_platform.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c -index a64265cca0..39bbb12675 100644 ---- a/hw/i386/xen/xen_platform.c -+++ b/hw/i386/xen/xen_platform.c -@@ -30,6 +30,7 @@ - #include "hw/pci/pci.h" - #include "hw/xen/xen_common.h" - #include "migration/vmstate.h" -+#include "hw/virtio/virtio-bus.h" - #include "hw/xen/xen-legacy-backend.h" - #include "trace.h" - #include "sysemu/xen.h" -@@ -114,7 +115,8 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o) - /* We have to ignore passthrough devices */ - if (pci_get_word(d->config + PCI_CLASS_DEVICE) == - PCI_CLASS_NETWORK_ETHERNET -- && strcmp(d->name, "xen-pci-passthrough") != 0) { -+ && strcmp(d->name, "xen-pci-passthrough") != 0 -+ && !qdev_get_child_bus(&d->qdev, TYPE_VIRTIO_BUS)) { - object_unparent(OBJECT(d)); - } - } -@@ -191,6 +193,11 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *opaque) - return; - } - -+ /* Ignore virtio devices */ -+ if (qdev_get_child_bus(&d->qdev, TYPE_VIRTIO_BUS)) { -+ return; -+ } -+ - switch (pci_get_word(d->config + PCI_CLASS_DEVICE)) { - case PCI_CLASS_STORAGE_IDE: - pci_xen_ide_unplug(DEVICE(d), aux); --- -2.25.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen_common-return-error-from-xen_create_ioreq_server.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen_common-return-error-from-xen_create_ioreq_server.patch deleted file mode 100644 index d4349b1d..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0001-xen_common-return-error-from-xen_create_ioreq_server.patch +++ /dev/null @@ -1,55 +0,0 @@ -From ef4d512aff004c62d550cdd64329c6c1acd0f217 Mon Sep 17 00:00:00 2001 -From: Stefano Stabellini -Date: Fri, 1 Jul 2022 18:48:03 -0700 -Subject: [PATCH 01/16] xen_common: return error from xen_create_ioreq_server - -Signed-off-by: Stefano Stabellini ---- - include/hw/xen/xen_common.h | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h -index 77ce17d8a4..c2d2f36bde 100644 ---- a/include/hw/xen/xen_common.h -+++ b/include/hw/xen/xen_common.h -@@ -467,8 +467,8 @@ static inline void xen_unmap_pcidev(domid_t dom, - { - } - --static inline void xen_create_ioreq_server(domid_t dom, -- ioservid_t *ioservid) -+static inline int xen_create_ioreq_server(domid_t dom, -+ ioservid_t *ioservid) - { - } - -@@ -600,8 +600,8 @@ static inline void xen_unmap_pcidev(domid_t dom, - PCI_FUNC(pci_dev->devfn)); - } - --static inline void xen_create_ioreq_server(domid_t dom, -- ioservid_t *ioservid) -+static inline int xen_create_ioreq_server(domid_t dom, -+ ioservid_t *ioservid) - { - int rc = xendevicemodel_create_ioreq_server(xen_dmod, dom, - HVM_IOREQSRV_BUFIOREQ_ATOMIC, -@@ -609,12 +609,14 @@ static inline void xen_create_ioreq_server(domid_t dom, - - if (rc == 0) { - trace_xen_ioreq_server_create(*ioservid); -- return; -+ return rc; - } - - *ioservid = 0; - use_default_ioreq_server = true; - trace_xen_default_ioreq_server(); -+ -+ return rc; - } - - static inline void xen_destroy_ioreq_server(domid_t dom, --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0002-xen-add-pseudo-RAM-region-for-grant-mappings.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0002-xen-add-pseudo-RAM-region-for-grant-mappings.patch deleted file mode 100644 index 8facb189..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0002-xen-add-pseudo-RAM-region-for-grant-mappings.patch +++ /dev/null @@ -1,252 +0,0 @@ -From e18daac2f6d3f60c8217f44189a91cf8240a591f Mon Sep 17 00:00:00 2001 -From: Juergen Gross -Date: Thu, 20 May 2021 11:19:58 +0200 -Subject: [PATCH 2/8] xen: add pseudo RAM region for grant mappings - -Add a memory region which can be used to automatically map granted -memory. It is starting at 0x8000000000000000ULL in order to be able to -distinguish it from normal RAM. - -For this reason the xen.ram memory region is expanded, which has no -further impact as it is used just as a container of the real RAM -regions and now the grant region. - -Signed-off-by: Juergen Gross -Signed-off-by: Vikram Garhwal -Acked-by: Stefano Stabellini ---- - hw/i386/xen/xen-hvm.c | 3 ++ - hw/xen/xen-hvm-common.c | 4 +-- - hw/xen/xen-mapcache.c | 28 +++++++++++++++ - include/exec/ram_addr.h | 1 + - include/hw/xen/xen-hvm-common.h | 2 ++ - include/hw/xen/xen_pvdev.h | 3 ++ - include/sysemu/xen-mapcache.h | 3 ++ - softmmu/physmem.c | 61 ++++++++++++++++++++------------- - 8 files changed, 80 insertions(+), 25 deletions(-) - -diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c -index 36d87555a9..2dcc2e1179 100644 ---- a/hw/i386/xen/xen-hvm.c -+++ b/hw/i386/xen/xen-hvm.c -@@ -171,6 +171,9 @@ static void xen_ram_init(PCMachineState *pcms, - x86ms->above_4g_mem_size); - memory_region_add_subregion(sysmem, 0x100000000ULL, &ram_hi); - } -+ -+ /* Add grant mappings as a pseudo RAM region. */ -+ ram_grants = *xen_init_grant_ram(); - } - - static XenPhysmap *get_physmapping(hwaddr start_addr, ram_addr_t size) -diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c -index 7e7d23397f..abd6e379d3 100644 ---- a/hw/xen/xen-hvm-common.c -+++ b/hw/xen/xen-hvm-common.c -@@ -10,7 +10,7 @@ - #include "hw/boards.h" - #include "hw/xen/arch_hvm.h" - --MemoryRegion ram_memory; -+MemoryRegion ram_memory, ram_grants; - - MemoryListener xen_io_listener = { - .name = "xen-io", -@@ -742,7 +742,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, - return; - } - -- if (mr == &ram_memory) { -+ if (mr == &ram_memory || mr == &ram_grants) { - return; - } - -diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c -index a2f93096e7..0b75f1633a 100644 ---- a/hw/xen/xen-mapcache.c -+++ b/hw/xen/xen-mapcache.c -@@ -14,7 +14,10 @@ - - #include - -+#include "hw/xen/xen-hvm-common.h" - #include "hw/xen/xen-legacy-backend.h" -+#include "hw/xen/xen_pvdev.h" -+ - #include "qemu/bitmap.h" - - #include "sysemu/runstate.h" -@@ -597,3 +600,28 @@ uint8_t *xen_replace_cache_entry(hwaddr old_phys_addr, - mapcache_unlock(); - return p; - } -+ -+MemoryRegion *xen_init_grant_ram(void) -+{ -+ RAMBlock *block; -+ -+ memory_region_init(&ram_grants, NULL, "xen.grants", -+ XEN_MAX_VIRTIO_GRANTS * XC_PAGE_SIZE); -+ block = g_malloc0(sizeof(*block)); -+ block->mr = &ram_grants; -+ block->used_length = XEN_MAX_VIRTIO_GRANTS * XC_PAGE_SIZE; -+ block->max_length = XEN_MAX_VIRTIO_GRANTS * XC_PAGE_SIZE; -+ block->fd = -1; -+ block->page_size = XC_PAGE_SIZE; -+ block->host = (void *)XEN_GRANT_ADDR_OFF; -+ block->offset = XEN_GRANT_ADDR_OFF; -+ block->flags = RAM_PREALLOC; -+ ram_grants.ram_block = block; -+ ram_grants.ram = true; -+ ram_grants.terminates = true; -+ ram_block_add_list(block); -+ memory_region_add_subregion(get_system_memory(), XEN_GRANT_ADDR_OFF, -+ &ram_grants); -+ -+ return &ram_grants; -+} -diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h -index f3e0c78161..e60b055867 100644 ---- a/include/exec/ram_addr.h -+++ b/include/exec/ram_addr.h -@@ -137,6 +137,7 @@ void qemu_ram_free(RAMBlock *block); - int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp); - - void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length); -+void ram_block_add_list(RAMBlock *new_block); - - /* Clear whole block of mem */ - static inline void qemu_ram_block_writeback(RAMBlock *block) -diff --git a/include/hw/xen/xen-hvm-common.h b/include/hw/xen/xen-hvm-common.h -index 2979f84ee2..6f7cc05d38 100644 ---- a/include/hw/xen/xen-hvm-common.h -+++ b/include/hw/xen/xen-hvm-common.h -@@ -16,6 +16,8 @@ - #include - - extern MemoryRegion ram_memory; -+ -+extern MemoryRegion ram_grants; - extern MemoryListener xen_io_listener; - extern DeviceListener xen_device_listener; - -diff --git a/include/hw/xen/xen_pvdev.h b/include/hw/xen/xen_pvdev.h -index 7cd4bc2b82..36cd3ec1d4 100644 ---- a/include/hw/xen/xen_pvdev.h -+++ b/include/hw/xen/xen_pvdev.h -@@ -78,4 +78,7 @@ int xen_pv_send_notify(struct XenLegacyDevice *xendev); - void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level, - const char *fmt, ...) G_GNUC_PRINTF(3, 4); - -+#define XEN_GRANT_ADDR_OFF 0x8000000000000000ULL -+#define XEN_MAX_VIRTIO_GRANTS 65536 -+ - #endif /* QEMU_HW_XEN_PVDEV_H */ -diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h -index c8e7c2f6cf..f4bedb1c11 100644 ---- a/include/sysemu/xen-mapcache.h -+++ b/include/sysemu/xen-mapcache.h -@@ -10,6 +10,7 @@ - #define XEN_MAPCACHE_H - - #include "exec/cpu-common.h" -+#include "exec/ram_addr.h" - - typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr phys_offset, - ram_addr_t size); -@@ -25,6 +26,8 @@ void xen_invalidate_map_cache(void); - uint8_t *xen_replace_cache_entry(hwaddr old_phys_addr, - hwaddr new_phys_addr, - hwaddr size); -+MemoryRegion *xen_init_grant_ram(void); -+ - #else - - static inline void xen_map_cache_init(phys_offset_to_gaddr_t f, -diff --git a/softmmu/physmem.c b/softmmu/physmem.c -index dc3c3e5f2e..63ba5f7495 100644 ---- a/softmmu/physmem.c -+++ b/softmmu/physmem.c -@@ -1971,12 +1971,46 @@ static void dirty_memory_extend(ram_addr_t old_ram_size, - } - } - -+static void ram_block_add_list_locked(RAMBlock *new_block) -+ { -+ RAMBlock *block; -+ RAMBlock *last_block = NULL; -+ -+ /* Keep the list sorted from biggest to smallest block. Unlike QTAILQ, -+ * QLIST (which has an RCU-friendly variant) does not have insertion at -+ * tail, so save the last element in last_block. -+ */ -+ RAMBLOCK_FOREACH(block) { -+ last_block = block; -+ if (block->max_length < new_block->max_length) { -+ break; -+ } -+ } -+ if (block) { -+ QLIST_INSERT_BEFORE_RCU(block, new_block, next); -+ } else if (last_block) { -+ QLIST_INSERT_AFTER_RCU(last_block, new_block, next); -+ } else { /* list is empty */ -+ QLIST_INSERT_HEAD_RCU(&ram_list.blocks, new_block, next); -+ } -+ ram_list.mru_block = NULL; -+ -+ /* Write list before version */ -+ smp_wmb(); -+ ram_list.version++; -+} -+ -+void ram_block_add_list(RAMBlock *new_block) -+{ -+ qemu_mutex_lock_ramlist(); -+ ram_block_add_list_locked(new_block); -+ qemu_mutex_unlock_ramlist(); -+} -+ - static void ram_block_add(RAMBlock *new_block, Error **errp) - { - const bool noreserve = qemu_ram_is_noreserve(new_block); - const bool shared = qemu_ram_is_shared(new_block); -- RAMBlock *block; -- RAMBlock *last_block = NULL; - ram_addr_t old_ram_size, new_ram_size; - Error *err = NULL; - -@@ -2014,28 +2048,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) - if (new_ram_size > old_ram_size) { - dirty_memory_extend(old_ram_size, new_ram_size); - } -- /* Keep the list sorted from biggest to smallest block. Unlike QTAILQ, -- * QLIST (which has an RCU-friendly variant) does not have insertion at -- * tail, so save the last element in last_block. -- */ -- RAMBLOCK_FOREACH(block) { -- last_block = block; -- if (block->max_length < new_block->max_length) { -- break; -- } -- } -- if (block) { -- QLIST_INSERT_BEFORE_RCU(block, new_block, next); -- } else if (last_block) { -- QLIST_INSERT_AFTER_RCU(last_block, new_block, next); -- } else { /* list is empty */ -- QLIST_INSERT_HEAD_RCU(&ram_list.blocks, new_block, next); -- } -- ram_list.mru_block = NULL; - -- /* Write list before version */ -- smp_wmb(); -- ram_list.version++; -+ ram_block_add_list_locked(new_block); -+ - qemu_mutex_unlock_ramlist(); - - cpu_physical_memory_set_dirty_range(new_block->offset, --- -2.25.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0002-xen-mapcache-move-xen-mapcache.c-to-hw-xen.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0002-xen-mapcache-move-xen-mapcache.c-to-hw-xen.patch deleted file mode 100644 index 35ca6df4..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0002-xen-mapcache-move-xen-mapcache.c-to-hw-xen.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 423468bdb3728154e95af18ef755bc75c5d59a3a Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Thu, 30 Jun 2022 18:19:50 -0700 -Subject: [PATCH 02/16] xen-mapcache: move xen-mapcache.c to hw/xen - -xen-mapcache.c contains common functions which are useful for Xen on ARM -IOREQ handling. Moving it out of i386 to hw/xen for commong access. - -Signed-off-by: Vikram Garhwal -Reviewed-by: Stefano Stabellini -Signed-off-by: Stefano Stabellini ---- - hw/i386/meson.build | 1 + - hw/i386/xen/meson.build | 1 - - hw/i386/xen/trace-events | 5 ----- - hw/xen/meson.build | 4 ++++ - hw/xen/trace-events | 5 +++++ - hw/{i386 => }/xen/xen-mapcache.c | 0 - 6 files changed, 10 insertions(+), 6 deletions(-) - rename hw/{i386 => }/xen/xen-mapcache.c (100%) - -diff --git a/hw/i386/meson.build b/hw/i386/meson.build -index 213e2e82b3..cfdbfdcbcb 100644 ---- a/hw/i386/meson.build -+++ b/hw/i386/meson.build -@@ -33,5 +33,6 @@ subdir('kvm') - subdir('xen') - - i386_ss.add_all(xenpv_ss) -+i386_ss.add_all(xen_ss) - - hw_arch += {'i386': i386_ss} -diff --git a/hw/i386/xen/meson.build b/hw/i386/xen/meson.build -index be84130300..2fcc46e6ca 100644 ---- a/hw/i386/xen/meson.build -+++ b/hw/i386/xen/meson.build -@@ -1,6 +1,5 @@ - i386_ss.add(when: 'CONFIG_XEN', if_true: files( - 'xen-hvm.c', -- 'xen-mapcache.c', - 'xen_apic.c', - 'xen_platform.c', - 'xen_pvdevice.c', -diff --git a/hw/i386/xen/trace-events b/hw/i386/xen/trace-events -index 5d6be61090..a0c89d91c4 100644 ---- a/hw/i386/xen/trace-events -+++ b/hw/i386/xen/trace-events -@@ -21,8 +21,3 @@ xen_map_resource_ioreq(uint32_t id, void *addr) "id: %u addr: %p" - cpu_ioreq_config_read(void *req, uint32_t sbdf, uint32_t reg, uint32_t size, uint32_t data) "I/O=%p sbdf=0x%x reg=%u size=%u data=0x%x" - cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_t reg, uint32_t size, uint32_t data) "I/O=%p sbdf=0x%x reg=%u size=%u data=0x%x" - --# xen-mapcache.c --xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 --xen_remap_bucket(uint64_t index) "index 0x%"PRIx64 --xen_map_cache_return(void* ptr) "%p" -- -diff --git a/hw/xen/meson.build b/hw/xen/meson.build -index ae0ace3046..19d0637c46 100644 ---- a/hw/xen/meson.build -+++ b/hw/xen/meson.build -@@ -22,3 +22,7 @@ else - endif - - specific_ss.add_all(when: ['CONFIG_XEN', xen], if_true: xen_specific_ss) -+ -+xen_ss = ss.source_set() -+ -+xen_ss.add(when: 'CONFIG_XEN', if_true: files('xen-mapcache.c')) -diff --git a/hw/xen/trace-events b/hw/xen/trace-events -index 3da3fd8348..2c8f238f42 100644 ---- a/hw/xen/trace-events -+++ b/hw/xen/trace-events -@@ -41,3 +41,8 @@ xs_node_vprintf(char *path, char *value) "%s %s" - xs_node_vscanf(char *path, char *value) "%s %s" - xs_node_watch(char *path) "%s" - xs_node_unwatch(char *path) "%s" -+ -+# xen-mapcache.c -+xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 -+xen_remap_bucket(uint64_t index) "index 0x%"PRIx64 -+xen_map_cache_return(void* ptr) "%p" -diff --git a/hw/i386/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c -similarity index 100% -rename from hw/i386/xen/xen-mapcache.c -rename to hw/xen/xen-mapcache.c --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0003-hw-i386-xen-rearrange-xen_hvm_init_pc.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0003-hw-i386-xen-rearrange-xen_hvm_init_pc.patch deleted file mode 100644 index 1113cf39..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0003-hw-i386-xen-rearrange-xen_hvm_init_pc.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 4472924c800e9dbf46e4c2432565d3e406b35d27 Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Fri, 1 Jul 2022 16:32:33 -0700 -Subject: [PATCH 03/16] hw/i386/xen: rearrange xen_hvm_init_pc - -Move references to: -- xen_get_vmport_regs_pfn -- xen_suspend_notifier -- xen_wakeup_notifier -- xen_ram_init - -towards the end of the function. This is done to keep the the common -ioreq functions in one place which will be moved to new function in next -patch in order to make it useful to ARM machines also. - -Signed-off-by: Vikram Garhwal -Signed-off-by: Stefano Stabellini -Reviewed-by: Stefano Stabellini ---- - hw/i386/xen/xen-hvm.c | 49 ++++++++++++++++++++++--------------------- - 1 file changed, 25 insertions(+), 24 deletions(-) - -diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c -index e4293d6d66..b27484ad22 100644 ---- a/hw/i386/xen/xen-hvm.c -+++ b/hw/i386/xen/xen-hvm.c -@@ -1416,12 +1416,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) - state->exit.notify = xen_exit_notifier; - qemu_add_exit_notifier(&state->exit); - -- state->suspend.notify = xen_suspend_notifier; -- qemu_register_suspend_notifier(&state->suspend); -- -- state->wakeup.notify = xen_wakeup_notifier; -- qemu_register_wakeup_notifier(&state->wakeup); -- - /* - * Register wake-up support in QMP query-current-machine API - */ -@@ -1432,23 +1426,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) - goto err; - } - -- rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn); -- if (!rc) { -- DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn); -- state->shared_vmport_page = -- xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, -- 1, &ioreq_pfn, NULL); -- if (state->shared_vmport_page == NULL) { -- error_report("map shared vmport IO page returned error %d handle=%p", -- errno, xen_xc); -- goto err; -- } -- } else if (rc != -ENOSYS) { -- error_report("get vmport regs pfn returned error %d, rc=%d", -- errno, rc); -- goto err; -- } -- - /* Note: cpus is empty at this point in init */ - state->cpu_by_vcpu_id = g_new0(CPUState *, max_cpus); - -@@ -1486,7 +1463,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) - #else - xen_map_cache_init(NULL, state); - #endif -- xen_ram_init(pcms, ms->ram_size, ram_memory); - - qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state); - -@@ -1513,6 +1489,31 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) - QLIST_INIT(&xen_physmap); - xen_read_physmap(state); - -+ state->suspend.notify = xen_suspend_notifier; -+ qemu_register_suspend_notifier(&state->suspend); -+ -+ state->wakeup.notify = xen_wakeup_notifier; -+ qemu_register_wakeup_notifier(&state->wakeup); -+ -+ rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn); -+ if (!rc) { -+ DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn); -+ state->shared_vmport_page = -+ xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, -+ 1, &ioreq_pfn, NULL); -+ if (state->shared_vmport_page == NULL) { -+ error_report("map shared vmport IO page returned error %d handle=%p", -+ errno, xen_xc); -+ goto err; -+ } -+ } else if (rc != -ENOSYS) { -+ error_report("get vmport regs pfn returned error %d, rc=%d", -+ errno, rc); -+ goto err; -+ } -+ -+ xen_ram_init(pcms, ms->ram_size, ram_memory); -+ - /* Disable ACPI build because Xen handles it */ - pcms->acpi_build_enabled = false; - --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0003-softmmu-let-qemu_map_ram_ptr-use-qemu_ram_ptr_length.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0003-softmmu-let-qemu_map_ram_ptr-use-qemu_ram_ptr_length.patch deleted file mode 100644 index bff815bc..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0003-softmmu-let-qemu_map_ram_ptr-use-qemu_ram_ptr_length.patch +++ /dev/null @@ -1,113 +0,0 @@ -From cb4be1f7185c5974523c764f3f6efe3af6633d71 Mon Sep 17 00:00:00 2001 -From: Juergen Gross -Date: Thu, 20 May 2021 11:54:48 +0200 -Subject: [PATCH 3/8] softmmu: let qemu_map_ram_ptr() use qemu_ram_ptr_length() - -qemu_map_ram_ptr() and qemu_ram_ptr_length() share quite some code, so -modify qemu_ram_ptr_length() a little bit and use it for -qemu_map_ram_ptr(), too. - -Signed-off-by: Juergen Gross -Acked-by: Stefano Stabellini ---- - softmmu/physmem.c | 56 ++++++++++++++++++----------------------------- - 1 file changed, 21 insertions(+), 35 deletions(-) - -diff --git a/softmmu/physmem.c b/softmmu/physmem.c -index 63ba5f7495..439a53a1be 100644 ---- a/softmmu/physmem.c -+++ b/softmmu/physmem.c -@@ -2306,38 +2306,7 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) - } - #endif /* !_WIN32 */ - --/* Return a host pointer to ram allocated with qemu_ram_alloc. -- * This should not be used for general purpose DMA. Use address_space_map -- * or address_space_rw instead. For local memory (e.g. video ram) that the -- * device owns, use memory_region_get_ram_ptr. -- * -- * Called within RCU critical section. -- */ --void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr) --{ -- RAMBlock *block = ram_block; -- -- if (block == NULL) { -- block = qemu_get_ram_block(addr); -- addr -= block->offset; -- } -- -- if (xen_enabled() && block->host == NULL) { -- /* We need to check if the requested address is in the RAM -- * because we don't want to map the entire memory in QEMU. -- * In that case just map until the end of the page. -- */ -- if (block->offset == 0) { -- return xen_map_cache(addr, 0, 0, false); -- } -- -- block->host = xen_map_cache(block->offset, block->max_length, 1, false); -- } -- return ramblock_ptr(block, addr); --} -- --/* Return a host pointer to guest's ram. Similar to qemu_map_ram_ptr -- * but takes a size argument. -+/* Return a host pointer to guest's ram. - * - * Called within RCU critical section. - */ -@@ -2345,7 +2314,9 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr, - hwaddr *size, bool lock) - { - RAMBlock *block = ram_block; -- if (*size == 0) { -+ hwaddr len = 0; -+ -+ if (size && *size == 0) { - return NULL; - } - -@@ -2353,7 +2324,10 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr, - block = qemu_get_ram_block(addr); - addr -= block->offset; - } -- *size = MIN(*size, block->max_length - addr); -+ if (size) { -+ *size = MIN(*size, block->max_length - addr); -+ len = *size; -+ } - - if (xen_enabled() && block->host == NULL) { - /* We need to check if the requested address is in the RAM -@@ -2361,7 +2335,7 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr, - * In that case just map the requested area. - */ - if (block->offset == 0) { -- return xen_map_cache(addr, *size, lock, lock); -+ return xen_map_cache(addr, len, lock, lock); - } - - block->host = xen_map_cache(block->offset, block->max_length, 1, lock); -@@ -2370,6 +2344,18 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr, - return ramblock_ptr(block, addr); - } - -+/* Return a host pointer to ram allocated with qemu_ram_alloc. -+ * This should not be used for general purpose DMA. Use address_space_map -+ * or address_space_rw instead. For local memory (e.g. video ram) that the -+ * device owns, use memory_region_get_ram_ptr. -+ * -+ * Called within RCU critical section. -+ */ -+void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr) -+{ -+ return qemu_ram_ptr_length(ram_block, addr, NULL, false); -+} -+ - /* Return the offset of a hostpointer within a ramblock */ - ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host) - { --- -2.25.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0004-xen-hvm-move-x86-specific-fields-out-of-XenIOState.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0004-xen-hvm-move-x86-specific-fields-out-of-XenIOState.patch deleted file mode 100644 index 4337e0c8..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0004-xen-hvm-move-x86-specific-fields-out-of-XenIOState.patch +++ /dev/null @@ -1,180 +0,0 @@ -From 2a01fa06d267f68148d3a6df50675edfe090601a Mon Sep 17 00:00:00 2001 -From: Stefano Stabellini -Date: Fri, 1 Jul 2022 18:16:52 -0700 -Subject: [PATCH 04/16] xen-hvm: move x86-specific fields out of XenIOState - -Move: -- shared_vmport_page -- log_for_dirtybit -- dirty_bitmap -- suspend -- wakeup - -out of XenIOState as they are only used on x86, especially the ones -related to dirty logging. - -Remove free_phys_offset that was unused. - -Signed-off-by: Stefano Stabellini ---- - hw/i386/xen/xen-hvm.c | 58 ++++++++++++++++++++----------------------- - 1 file changed, 27 insertions(+), 31 deletions(-) - -diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c -index b27484ad22..225cfdf8b7 100644 ---- a/hw/i386/xen/xen-hvm.c -+++ b/hw/i386/xen/xen-hvm.c -@@ -73,6 +73,7 @@ struct shared_vmport_iopage { - }; - typedef struct shared_vmport_iopage shared_vmport_iopage_t; - #endif -+static shared_vmport_iopage_t *shared_vmport_page; - - static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i) - { -@@ -95,6 +96,11 @@ typedef struct XenPhysmap { - } XenPhysmap; - - static QLIST_HEAD(, XenPhysmap) xen_physmap; -+static const XenPhysmap *log_for_dirtybit = NULL; -+/* Buffer used by xen_sync_dirty_bitmap */ -+static unsigned long *dirty_bitmap = NULL; -+static Notifier suspend; -+static Notifier wakeup; - - typedef struct XenPciDevice { - PCIDevice *pci_dev; -@@ -105,7 +111,6 @@ typedef struct XenPciDevice { - typedef struct XenIOState { - ioservid_t ioservid; - shared_iopage_t *shared_page; -- shared_vmport_iopage_t *shared_vmport_page; - buffered_iopage_t *buffered_io_page; - xenforeignmemory_resource_handle *fres; - QEMUTimer *buffered_io_timer; -@@ -125,14 +130,8 @@ typedef struct XenIOState { - MemoryListener io_listener; - QLIST_HEAD(, XenPciDevice) dev_list; - DeviceListener device_listener; -- hwaddr free_phys_offset; -- const XenPhysmap *log_for_dirtybit; -- /* Buffer used by xen_sync_dirty_bitmap */ -- unsigned long *dirty_bitmap; - - Notifier exit; -- Notifier suspend; -- Notifier wakeup; - } XenIOState; - - /* Xen specific function for piix pci */ -@@ -462,10 +461,10 @@ static int xen_remove_from_physmap(XenIOState *state, - } - - QLIST_REMOVE(physmap, list); -- if (state->log_for_dirtybit == physmap) { -- state->log_for_dirtybit = NULL; -- g_free(state->dirty_bitmap); -- state->dirty_bitmap = NULL; -+ if (log_for_dirtybit == physmap) { -+ log_for_dirtybit = NULL; -+ g_free(dirty_bitmap); -+ dirty_bitmap = NULL; - } - g_free(physmap); - -@@ -626,16 +625,16 @@ static void xen_sync_dirty_bitmap(XenIOState *state, - return; - } - -- if (state->log_for_dirtybit == NULL) { -- state->log_for_dirtybit = physmap; -- state->dirty_bitmap = g_new(unsigned long, bitmap_size); -- } else if (state->log_for_dirtybit != physmap) { -+ if (log_for_dirtybit == NULL) { -+ log_for_dirtybit = physmap; -+ dirty_bitmap = g_new(unsigned long, bitmap_size); -+ } else if (log_for_dirtybit != physmap) { - /* Only one range for dirty bitmap can be tracked. */ - return; - } - - rc = xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS, -- npages, state->dirty_bitmap); -+ npages, dirty_bitmap); - if (rc < 0) { - #ifndef ENODATA - #define ENODATA ENOENT -@@ -650,7 +649,7 @@ static void xen_sync_dirty_bitmap(XenIOState *state, - } - - for (i = 0; i < bitmap_size; i++) { -- unsigned long map = state->dirty_bitmap[i]; -+ unsigned long map = dirty_bitmap[i]; - while (map != 0) { - j = ctzl(map); - map &= ~(1ul << j); -@@ -676,12 +675,10 @@ static void xen_log_start(MemoryListener *listener, - static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section, - int old, int new) - { -- XenIOState *state = container_of(listener, XenIOState, memory_listener); -- - if (old & ~new & (1 << DIRTY_MEMORY_VGA)) { -- state->log_for_dirtybit = NULL; -- g_free(state->dirty_bitmap); -- state->dirty_bitmap = NULL; -+ log_for_dirtybit = NULL; -+ g_free(dirty_bitmap); -+ dirty_bitmap = NULL; - /* Disable dirty bit tracking */ - xen_track_dirty_vram(xen_domid, 0, 0, NULL); - } -@@ -1021,9 +1018,9 @@ static void handle_vmport_ioreq(XenIOState *state, ioreq_t *req) - { - vmware_regs_t *vmport_regs; - -- assert(state->shared_vmport_page); -+ assert(shared_vmport_page); - vmport_regs = -- &state->shared_vmport_page->vcpu_vmport_regs[state->send_vcpu]; -+ &shared_vmport_page->vcpu_vmport_regs[state->send_vcpu]; - QEMU_BUILD_BUG_ON(sizeof(*req) < sizeof(*vmport_regs)); - - current_cpu = state->cpu_by_vcpu_id[state->send_vcpu]; -@@ -1468,7 +1465,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) - - state->memory_listener = xen_memory_listener; - memory_listener_register(&state->memory_listener, &address_space_memory); -- state->log_for_dirtybit = NULL; - - state->io_listener = xen_io_listener; - memory_listener_register(&state->io_listener, &address_space_io); -@@ -1489,19 +1485,19 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) - QLIST_INIT(&xen_physmap); - xen_read_physmap(state); - -- state->suspend.notify = xen_suspend_notifier; -- qemu_register_suspend_notifier(&state->suspend); -+ suspend.notify = xen_suspend_notifier; -+ qemu_register_suspend_notifier(&suspend); - -- state->wakeup.notify = xen_wakeup_notifier; -- qemu_register_wakeup_notifier(&state->wakeup); -+ wakeup.notify = xen_wakeup_notifier; -+ qemu_register_wakeup_notifier(&wakeup); - - rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn); - if (!rc) { - DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn); -- state->shared_vmport_page = -+ shared_vmport_page = - xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, - 1, &ioreq_pfn, NULL); -- if (state->shared_vmport_page == NULL) { -+ if (shared_vmport_page == NULL) { - error_report("map shared vmport IO page returned error %d handle=%p", - errno, xen_xc); - goto err; --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0004-xen-let-xen_ram_addr_from_mapcache-return-1-in-case-.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0004-xen-let-xen_ram_addr_from_mapcache-return-1-in-case-.patch deleted file mode 100644 index 25dc0ae0..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0004-xen-let-xen_ram_addr_from_mapcache-return-1-in-case-.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 7dfa8828bd2e61fc5bf2bf6294aad16b2bf4ff8a Mon Sep 17 00:00:00 2001 -From: Juergen Gross -Date: Thu, 20 May 2021 13:31:32 +0200 -Subject: [PATCH 4/8] xen: let xen_ram_addr_from_mapcache() return -1 in case - of not found entry - -Today xen_ram_addr_from_mapcache() will either abort() or return 0 in -case it can't find a matching entry for a pointer value. Both cases -are bad, so change that to return an invalid address instead. - -Signed-off-by: Juergen Gross -Acked-by: Stefano Stabellini ---- - hw/xen/xen-mapcache.c | 12 +++--------- - 1 file changed, 3 insertions(+), 9 deletions(-) - -diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c -index 0b75f1633a..e53e7221f1 100644 ---- a/hw/xen/xen-mapcache.c -+++ b/hw/xen/xen-mapcache.c -@@ -405,13 +405,8 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) - } - } - if (!found) { -- fprintf(stderr, "%s, could not find %p\n", __func__, ptr); -- QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { -- DPRINTF(" "TARGET_FMT_plx" -> %p is present\n", reventry->paddr_index, -- reventry->vaddr_req); -- } -- abort(); -- return 0; -+ mapcache_unlock(); -+ return RAM_ADDR_INVALID; - } - - entry = &mapcache->entry[paddr_index % mapcache->nr_buckets]; -@@ -419,8 +414,7 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) - entry = entry->next; - } - if (!entry) { -- DPRINTF("Trying to find address %p that is not in the mapcache!\n", ptr); -- raddr = 0; -+ raddr = RAM_ADDR_INVALID; - } else { - raddr = (reventry->paddr_index << MCACHE_BUCKET_SHIFT) + - ((unsigned long) ptr - (unsigned long) entry->vaddr_base); --- -2.25.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0005-memory-add-MemoryRegion-map-and-unmap-callbacks.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0005-memory-add-MemoryRegion-map-and-unmap-callbacks.patch deleted file mode 100644 index db6d8fe5..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0005-memory-add-MemoryRegion-map-and-unmap-callbacks.patch +++ /dev/null @@ -1,150 +0,0 @@ -From bd32a130ca633eae7cf0f4ff0fa856004d413df0 Mon Sep 17 00:00:00 2001 -From: Juergen Gross -Date: Thu, 27 May 2021 15:27:55 +0200 -Subject: [PATCH 5/8] memory: add MemoryRegion map and unmap callbacks - -In order to support mapping and unmapping guest memory dynamically to -and from qemu during address_space_[un]map() operations add the map() -and unmap() callbacks to MemoryRegionOps. - -Those will be used e.g. for Xen grant mappings when performing guest -I/Os. - -Signed-off-by: Juergen Gross -Signed-off-by: Vikram Garhwal -Acked-by: Stefano Stabellini ---- - include/exec/memory.h | 19 +++++++++++++++++ - softmmu/physmem.c | 47 +++++++++++++++++++++++++++++++++---------- - 2 files changed, 55 insertions(+), 11 deletions(-) - -diff --git a/include/exec/memory.h b/include/exec/memory.h -index bfb1de8eea..19e2aac694 100644 ---- a/include/exec/memory.h -+++ b/include/exec/memory.h -@@ -245,6 +245,25 @@ struct MemoryRegionOps { - unsigned size, - MemTxAttrs attrs); - -+ /* Dynamically create mapping. @addr is the guest address to map; @plen -+ * is the pointer to the usable length of the buffer. -+ * @mr contents can be changed in case a new memory region is created for -+ * the mapping. -+ * Returns the buffer address for accessing the data. */ -+ void *(*map)(MemoryRegion **mr, -+ hwaddr addr, -+ hwaddr *plen, -+ bool is_write, -+ MemTxAttrs attrs); -+ -+ /* Unmap an area obtained via map() before. */ -+ void (*unmap)(MemoryRegion *mr, -+ void *buffer, -+ ram_addr_t addr, -+ hwaddr len, -+ bool is_write, -+ hwaddr access_len); -+ - enum device_endian endianness; - /* Guest-visible constraints: */ - struct { -diff --git a/softmmu/physmem.c b/softmmu/physmem.c -index 439a53a1be..2038240311 100644 ---- a/softmmu/physmem.c -+++ b/softmmu/physmem.c -@@ -3237,7 +3237,7 @@ void *address_space_map(AddressSpace *as, - hwaddr len = *plen; - hwaddr l, xlat; - MemoryRegion *mr; -- void *ptr; -+ void *ptr = NULL; - FlatView *fv; - - if (len == 0) { -@@ -3273,10 +3273,17 @@ void *address_space_map(AddressSpace *as, - - - memory_region_ref(mr); -+ -+ if (mr->ops && mr->ops->map) { -+ ptr = mr->ops->map(&mr, addr, plen, is_write, attrs); -+ } -+ - *plen = flatview_extend_translation(fv, addr, len, mr, xlat, - l, is_write, attrs); - fuzz_dma_read_cb(addr, *plen, mr); -- ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true); -+ if (ptr == NULL) { -+ ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true); -+ } - - return ptr; - } -@@ -3294,11 +3301,16 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, - - mr = memory_region_from_host(buffer, &addr1); - assert(mr != NULL); -- if (is_write) { -- invalidate_and_set_dirty(mr, addr1, access_len); -- } -- if (xen_enabled()) { -- xen_invalidate_map_cache_entry(buffer); -+ -+ if (mr->ops && mr->ops->unmap) { -+ mr->ops->unmap(mr, buffer, addr1, len, is_write, access_len); -+ } else { -+ if (is_write) { -+ invalidate_and_set_dirty(mr, addr1, access_len); -+ } -+ if (xen_enabled()) { -+ xen_invalidate_map_cache_entry(buffer); -+ } - } - memory_region_unref(mr); - return; -@@ -3370,10 +3382,17 @@ int64_t address_space_cache_init(MemoryRegionCache *cache, - * doing this if we found actual RAM, which behaves the same - * regardless of attributes; so UNSPECIFIED is fine. - */ -+ if (mr->ops && mr->ops->map) { -+ cache->ptr = mr->ops->map(&mr, addr, &l, is_write, -+ MEMTXATTRS_UNSPECIFIED); -+ } -+ - l = flatview_extend_translation(cache->fv, addr, len, mr, - cache->xlat, l, is_write, - MEMTXATTRS_UNSPECIFIED); -- cache->ptr = qemu_ram_ptr_length(mr->ram_block, cache->xlat, &l, true); -+ if (!cache->ptr) { -+ cache->ptr = qemu_ram_ptr_length(mr->ram_block, cache->xlat, &l, true); -+ } - } else { - cache->ptr = NULL; - } -@@ -3395,14 +3414,20 @@ void address_space_cache_invalidate(MemoryRegionCache *cache, - - void address_space_cache_destroy(MemoryRegionCache *cache) - { -- if (!cache->mrs.mr) { -+ MemoryRegion *mr = cache->mrs.mr; -+ -+ if (!mr) { - return; - } - -- if (xen_enabled()) { -+ if (mr->ops && mr->ops->unmap) { -+ mr->ops->unmap(mr, cache->ptr, cache->xlat, cache->len, -+ cache->is_write, cache->len); -+ } else if (xen_enabled()) { - xen_invalidate_map_cache_entry(cache->ptr); - } -- memory_region_unref(cache->mrs.mr); -+ -+ memory_region_unref(mr); - flatview_unref(cache->fv); - cache->mrs.mr = NULL; - cache->fv = NULL; --- -2.25.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0005-xen-hvm-create-arch_handle_ioreq-and-arch_xen_set_me.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0005-xen-hvm-create-arch_handle_ioreq-and-arch_xen_set_me.patch deleted file mode 100644 index 6b56a39e..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0005-xen-hvm-create-arch_handle_ioreq-and-arch_xen_set_me.patch +++ /dev/null @@ -1,192 +0,0 @@ -From c38436434fc888ba8844d99eab451f9b734e5e5b Mon Sep 17 00:00:00 2001 -From: Stefano Stabellini -Date: Fri, 1 Jul 2022 19:34:39 -0700 -Subject: [PATCH 05/16] xen-hvm: create arch_handle_ioreq and - arch_xen_set_memory - -In preparation to moving most of xen-hvm code to an arch-neutral -location, move the x86-specific portion of xen_set_memory to -arch_xen_set_memory. - -Also move handle_vmport_ioreq to arch_handle_ioreq. - -Signed-off-by: Stefano Stabellini -Signed-off-by: Vikram Garhwal -Reviewed-by: Stefano Stabellini ---- - hw/i386/xen/xen-hvm.c | 98 ++++++++++++++++++++-------------- - include/hw/i386/xen_arch_hvm.h | 10 ++++ - include/hw/xen/arch_hvm.h | 3 ++ - 3 files changed, 71 insertions(+), 40 deletions(-) - create mode 100644 include/hw/i386/xen_arch_hvm.h - create mode 100644 include/hw/xen/arch_hvm.h - -diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c -index 225cfdf8b7..178f0c68fc 100644 ---- a/hw/i386/xen/xen-hvm.c -+++ b/hw/i386/xen/xen-hvm.c -@@ -134,6 +134,8 @@ typedef struct XenIOState { - Notifier exit; - } XenIOState; - -+#include "hw/xen/arch_hvm.h" -+ - /* Xen specific function for piix pci */ - - int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) -@@ -476,10 +478,6 @@ static void xen_set_memory(struct MemoryListener *listener, - bool add) - { - XenIOState *state = container_of(listener, XenIOState, memory_listener); -- hwaddr start_addr = section->offset_within_address_space; -- ram_addr_t size = int128_get64(section->size); -- bool log_dirty = memory_region_is_logging(section->mr, DIRTY_MEMORY_VGA); -- hvmmem_type_t mem_type; - - if (section->mr == &ram_memory) { - return; -@@ -492,38 +490,7 @@ static void xen_set_memory(struct MemoryListener *listener, - section); - } - } -- -- if (!memory_region_is_ram(section->mr)) { -- return; -- } -- -- if (log_dirty != add) { -- return; -- } -- -- trace_xen_client_set_memory(start_addr, size, log_dirty); -- -- start_addr &= TARGET_PAGE_MASK; -- size = TARGET_PAGE_ALIGN(size); -- -- if (add) { -- if (!memory_region_is_rom(section->mr)) { -- xen_add_to_physmap(state, start_addr, size, -- section->mr, section->offset_within_region); -- } else { -- mem_type = HVMMEM_ram_ro; -- if (xen_set_mem_type(xen_domid, mem_type, -- start_addr >> TARGET_PAGE_BITS, -- size >> TARGET_PAGE_BITS)) { -- DPRINTF("xen_set_mem_type error, addr: "TARGET_FMT_plx"\n", -- start_addr); -- } -- } -- } else { -- if (xen_remove_from_physmap(state, start_addr, size) < 0) { -- DPRINTF("physmapping does not exist at "TARGET_FMT_plx"\n", start_addr); -- } -- } -+ arch_xen_set_memory(state, section, add); - } - - static void xen_region_add(MemoryListener *listener, -@@ -1051,9 +1018,6 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req) - case IOREQ_TYPE_COPY: - cpu_ioreq_move(req); - break; -- case IOREQ_TYPE_VMWARE_PORT: -- handle_vmport_ioreq(state, req); -- break; - case IOREQ_TYPE_TIMEOFFSET: - break; - case IOREQ_TYPE_INVALIDATE: -@@ -1063,7 +1027,7 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req) - cpu_ioreq_config(state, req); - break; - default: -- hw_error("Invalid ioreq type 0x%x\n", req->type); -+ arch_handle_ioreq(state, req); - } - if (req->dir == IOREQ_READ) { - trace_handle_ioreq_read(req, req->type, req->df, req->data_is_ptr, -@@ -1604,3 +1568,57 @@ void qmp_xen_set_global_dirty_log(bool enable, Error **errp) - memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION); - } - } -+ -+void arch_xen_set_memory(XenIOState *state,MemoryRegionSection *section, -+ bool add) -+{ -+ hwaddr start_addr = section->offset_within_address_space; -+ ram_addr_t size = int128_get64(section->size); -+ bool log_dirty = memory_region_is_logging(section->mr, DIRTY_MEMORY_VGA); -+ hvmmem_type_t mem_type; -+ -+ if (!memory_region_is_ram(section->mr)) { -+ return; -+ } -+ -+ if (log_dirty != add) { -+ return; -+ } -+ -+ trace_xen_client_set_memory(start_addr, size, log_dirty); -+ -+ start_addr &= TARGET_PAGE_MASK; -+ size = TARGET_PAGE_ALIGN(size); -+ -+ if (add) { -+ if (!memory_region_is_rom(section->mr)) { -+ xen_add_to_physmap(state, start_addr, size, -+ section->mr, section->offset_within_region); -+ } else { -+ mem_type = HVMMEM_ram_ro; -+ if (xen_set_mem_type(xen_domid, mem_type, -+ start_addr >> TARGET_PAGE_BITS, -+ size >> TARGET_PAGE_BITS)) { -+ DPRINTF("xen_set_mem_type error, addr: "TARGET_FMT_plx"\n", -+ start_addr); -+ } -+ } -+ } else { -+ if (xen_remove_from_physmap(state, start_addr, size) < 0) { -+ DPRINTF("physmapping does not exist at "TARGET_FMT_plx"\n", start_addr); -+ } -+ } -+} -+ -+void arch_handle_ioreq(XenIOState *state, ioreq_t *req) -+{ -+ switch (req->type) { -+ case IOREQ_TYPE_VMWARE_PORT: -+ handle_vmport_ioreq(state, req); -+ break; -+ default: -+ hw_error("Invalid ioreq type 0x%x\n", req->type); -+ } -+ -+ return; -+} -diff --git a/include/hw/i386/xen_arch_hvm.h b/include/hw/i386/xen_arch_hvm.h -new file mode 100644 -index 0000000000..1b2c71ba4f ---- /dev/null -+++ b/include/hw/i386/xen_arch_hvm.h -@@ -0,0 +1,10 @@ -+#ifndef HW_XEN_ARCH_I386_HVM_H -+#define HW_XEN_ARCH_I386_HVM_H -+ -+#include -+ -+void arch_handle_ioreq(XenIOState *state, ioreq_t *req); -+void arch_xen_set_memory(XenIOState *state, -+ MemoryRegionSection *section, -+ bool add); -+#endif -diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h -new file mode 100644 -index 0000000000..26674648d8 ---- /dev/null -+++ b/include/hw/xen/arch_hvm.h -@@ -0,0 +1,3 @@ -+#if defined(TARGET_I386) || defined(TARGET_X86_64) -+#include "hw/i386/xen_arch_hvm.h" -+#endif --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0006-xen-add-map-and-unmap-callbacks-for-grant-region.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0006-xen-add-map-and-unmap-callbacks-for-grant-region.patch deleted file mode 100644 index 87bbc3c6..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0006-xen-add-map-and-unmap-callbacks-for-grant-region.patch +++ /dev/null @@ -1,255 +0,0 @@ -From ef94d70d4a22c5282d6955a7ed066ef502e99829 Mon Sep 17 00:00:00 2001 -From: Juergen Gross -Date: Fri, 26 Aug 2022 13:57:06 +0200 -Subject: [PATCH 6/8] xen: add map and unmap callbacks for grant region - -Add the callbacks for mapping/unmapping guest memory via grants to the -special grant memory region. - -Signed-off-by: Juergen Gross -Signed-off-by: Vikram Garhwal -Signed-off-by: Stefano Stabellini -Acked-by: Stefano Stabellini ---- - hw/xen/xen-mapcache.c | 167 +++++++++++++++++++++++++++++++++++++++++- - softmmu/physmem.c | 11 ++- - 2 files changed, 173 insertions(+), 5 deletions(-) - -diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c -index e53e7221f1..f81b75d216 100644 ---- a/hw/xen/xen-mapcache.c -+++ b/hw/xen/xen-mapcache.c -@@ -9,6 +9,8 @@ - */ - - #include "qemu/osdep.h" -+#include "qemu/queue.h" -+#include "qemu/thread.h" - #include "qemu/units.h" - #include "qemu/error-report.h" - -@@ -24,6 +26,8 @@ - #include "sysemu/xen-mapcache.h" - #include "trace.h" - -+#include -+#include - - //#define MAPCACHE_DEBUG - -@@ -386,7 +390,7 @@ uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, - return p; - } - --ram_addr_t xen_ram_addr_from_mapcache(void *ptr) -+static ram_addr_t xen_ram_addr_from_mapcache_try(void *ptr) - { - MapCacheEntry *entry = NULL; - MapCacheRev *reventry; -@@ -595,10 +599,170 @@ uint8_t *xen_replace_cache_entry(hwaddr old_phys_addr, - return p; - } - -+struct XENMappedGrantRegion { -+ void *addr; -+ unsigned int pages; -+ unsigned int refs; -+ unsigned int prot; -+ uint32_t idx; -+ QLIST_ENTRY(XENMappedGrantRegion) list; -+}; -+ -+static xengnttab_handle *xen_region_gnttabdev; -+static QLIST_HEAD(GrantRegionList, XENMappedGrantRegion) xen_grant_mappings = -+ QLIST_HEAD_INITIALIZER(xen_grant_mappings); -+static QemuMutex xen_map_mutex; -+ -+static void *xen_map_grant_dyn(MemoryRegion **mr, hwaddr addr, hwaddr *plen, -+ bool is_write, MemTxAttrs attrs) -+{ -+ unsigned int page_off = addr & (XC_PAGE_SIZE - 1); -+ unsigned int i; -+ unsigned int nrefs = (page_off + *plen + XC_PAGE_SIZE - 1) >> XC_PAGE_SHIFT; -+ uint32_t ref = (addr - XEN_GRANT_ADDR_OFF) >> XC_PAGE_SHIFT; -+ uint32_t *refs; -+ unsigned int prot = PROT_READ; -+ struct XENMappedGrantRegion *mgr = NULL; -+ -+ if (is_write) { -+ prot |= PROT_WRITE; -+ } -+ -+ qemu_mutex_lock(&xen_map_mutex); -+ -+ QLIST_FOREACH(mgr, &xen_grant_mappings, list) { -+ if (mgr->idx == ref && -+ mgr->pages == nrefs && -+ (mgr->prot & prot) == prot) { -+ break; -+ } -+ } -+ if (!mgr) { -+ mgr = g_new(struct XENMappedGrantRegion, 1); -+ -+ if (nrefs == 1) { -+ refs = &ref; -+ } else { -+ refs = g_new(uint32_t, nrefs); -+ for (i = 0; i < nrefs; i++) { -+ refs[i] = ref + i; -+ } -+ } -+ mgr->addr = xengnttab_map_domain_grant_refs(xen_region_gnttabdev, nrefs, -+ xen_domid, refs, prot); -+ if (mgr->addr) { -+ mgr->pages = nrefs; -+ mgr->refs = 1; -+ mgr->prot = prot; -+ mgr->idx = ref; -+ -+ QLIST_INSERT_HEAD(&xen_grant_mappings, mgr, list); -+ } else { -+ g_free(mgr); -+ mgr = NULL; -+ } -+ } else { -+ mgr->refs++; -+ } -+ -+ qemu_mutex_unlock(&xen_map_mutex); -+ -+ if (nrefs > 1) { -+ g_free(refs); -+ } -+ -+ return mgr ? mgr->addr + page_off : NULL; -+} -+ -+static void xen_unmap_grant_dyn(MemoryRegion *mr, void *buffer, ram_addr_t addr, -+ hwaddr len, bool is_write, hwaddr access_len) -+{ -+ unsigned int page_off = (unsigned long)buffer & (XC_PAGE_SIZE - 1); -+ unsigned int nrefs = (page_off + len + XC_PAGE_SIZE - 1) >> XC_PAGE_SHIFT; -+ unsigned int prot = PROT_READ; -+ struct XENMappedGrantRegion *mgr = NULL; -+ -+ if (is_write) { -+ prot |= PROT_WRITE; -+ } -+ -+ qemu_mutex_lock(&xen_map_mutex); -+ -+ QLIST_FOREACH(mgr, &xen_grant_mappings, list) { -+ if (mgr->addr == buffer - page_off && -+ mgr->pages == nrefs && -+ (mgr->prot & prot) == prot) { -+ break; -+ } -+ } -+ if (mgr) { -+ mgr->refs--; -+ if (!mgr->refs) { -+ xengnttab_unmap(xen_region_gnttabdev, mgr->addr, nrefs); -+ -+ QLIST_REMOVE(mgr, list); -+ g_free(mgr); -+ } -+ } else { -+ error_report("xen_unmap_grant_dyn() trying to unmap unknown buffer"); -+ } -+ -+ qemu_mutex_unlock(&xen_map_mutex); -+} -+ -+static ram_addr_t xen_ram_addr_from_grant_cache(void *ptr) -+{ -+ unsigned int page_off = (unsigned long)ptr & (XC_PAGE_SIZE - 1); -+ struct XENMappedGrantRegion *mgr = NULL; -+ ram_addr_t raddr = RAM_ADDR_INVALID; -+ -+ qemu_mutex_lock(&xen_map_mutex); -+ -+ QLIST_FOREACH(mgr, &xen_grant_mappings, list) { -+ if (mgr->addr == ptr - page_off) { -+ break; -+ } -+ } -+ -+ if (mgr) { -+ raddr = (mgr->idx << XC_PAGE_SHIFT) + page_off + XEN_GRANT_ADDR_OFF; -+ } -+ -+ qemu_mutex_unlock(&xen_map_mutex); -+ -+ return raddr; -+} -+ -+ram_addr_t xen_ram_addr_from_mapcache(void *ptr) -+{ -+ ram_addr_t raddr; -+ -+ raddr = xen_ram_addr_from_mapcache_try(ptr); -+ if (raddr == RAM_ADDR_INVALID) { -+ raddr = xen_ram_addr_from_grant_cache(ptr); -+ } -+ -+ return raddr; -+} -+ -+static const struct MemoryRegionOps xen_grant_mr_ops = { -+ .map = xen_map_grant_dyn, -+ .unmap = xen_unmap_grant_dyn, -+ .endianness = DEVICE_LITTLE_ENDIAN, -+}; -+ - MemoryRegion *xen_init_grant_ram(void) - { - RAMBlock *block; - -+ qemu_mutex_init(&xen_map_mutex); -+ -+ xen_region_gnttabdev = xengnttab_open(NULL, 0); -+ if (xen_region_gnttabdev == NULL) { -+ fprintf(stderr, "can't open gnttab device\n"); -+ return NULL; -+ } -+ - memory_region_init(&ram_grants, NULL, "xen.grants", - XEN_MAX_VIRTIO_GRANTS * XC_PAGE_SIZE); - block = g_malloc0(sizeof(*block)); -@@ -613,6 +777,7 @@ MemoryRegion *xen_init_grant_ram(void) - ram_grants.ram_block = block; - ram_grants.ram = true; - ram_grants.terminates = true; -+ ram_grants.ops = &xen_grant_mr_ops; - ram_block_add_list(block); - memory_region_add_subregion(get_system_memory(), XEN_GRANT_ADDR_OFF, - &ram_grants); -diff --git a/softmmu/physmem.c b/softmmu/physmem.c -index 2038240311..6b2a02fc87 100644 ---- a/softmmu/physmem.c -+++ b/softmmu/physmem.c -@@ -2391,13 +2391,16 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, - - if (xen_enabled()) { - ram_addr_t ram_addr; -+ - RCU_READ_LOCK_GUARD(); - ram_addr = xen_ram_addr_from_mapcache(ptr); -- block = qemu_get_ram_block(ram_addr); -- if (block) { -- *offset = ram_addr - block->offset; -+ if (ram_addr != RAM_ADDR_INVALID) { -+ block = qemu_get_ram_block(ram_addr); -+ if (block) { -+ *offset = ram_addr - block->offset; -+ } -+ return block; - } -- return block; - } - - RCU_READ_LOCK_GUARD(); --- -2.25.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0006-xen-hvm-move-common-functions-to-hw-xen-xen-hvm-comm.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0006-xen-hvm-move-common-functions-to-hw-xen-xen-hvm-comm.patch deleted file mode 100644 index 7df302a2..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0006-xen-hvm-move-common-functions-to-hw-xen-xen-hvm-comm.patch +++ /dev/null @@ -1,2094 +0,0 @@ -From 87d362e72e65b604da7554657204344a6540d88c Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Fri, 1 Jul 2022 15:59:47 -0700 -Subject: [PATCH 06/16] xen-hvm: move common functions to - hw/xen/xen-hvm-common.c - -Extract common functionalities from xen-hvm.c and move them to -hw/xen/xen-hvm-common.c. These common functions are useful for creating -an IOREQ server. - -Moved the common usable IOREQ creation part to a new function -xen_register_ioreq() which can be used by both x86 and ARM machines. - -NOTE: This patch will break the build as the patch only involves moving -of functions. Build fixes will be in the next patch. - -Signed-off-by: Vikram Garhwal -Signed-off-by: Stefano Stabellini -Reviewed-by: Stefano Stabellini ---- - hw/i386/xen/trace-events | 14 - - hw/i386/xen/xen-hvm.c | 927 +------------------------------- - hw/xen/meson.build | 5 +- - hw/xen/trace-events | 14 + - hw/xen/xen-hvm-common.c | 861 +++++++++++++++++++++++++++++ - include/hw/i386/xen_arch_hvm.h | 1 + - include/hw/xen/xen-hvm-common.h | 98 ++++ - 7 files changed, 986 insertions(+), 934 deletions(-) - create mode 100644 hw/xen/xen-hvm-common.c - create mode 100644 include/hw/xen/xen-hvm-common.h - -diff --git a/hw/i386/xen/trace-events b/hw/i386/xen/trace-events -index a0c89d91c4..5d0a8d6dcf 100644 ---- a/hw/i386/xen/trace-events -+++ b/hw/i386/xen/trace-events -@@ -7,17 +7,3 @@ xen_platform_log(char *s) "xen platform: %s" - xen_pv_mmio_read(uint64_t addr) "WARNING: read from Xen PV Device MMIO space (address 0x%"PRIx64")" - xen_pv_mmio_write(uint64_t addr) "WARNING: write to Xen PV Device MMIO space (address 0x%"PRIx64")" - --# xen-hvm.c --xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: 0x%lx, size 0x%lx" --xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_dirty) "0x%"PRIx64" size 0x%lx, log_dirty %i" --handle_ioreq(void *req, uint32_t type, uint32_t dir, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p type=%d dir=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" --handle_ioreq_read(void *req, uint32_t type, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p read type=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" --handle_ioreq_write(void *req, uint32_t type, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p write type=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" --cpu_ioreq_pio(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p pio dir=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" --cpu_ioreq_pio_read_reg(void *req, uint64_t data, uint64_t addr, uint32_t size) "I/O=%p pio read reg data=0x%"PRIx64" port=0x%"PRIx64" size=%d" --cpu_ioreq_pio_write_reg(void *req, uint64_t data, uint64_t addr, uint32_t size) "I/O=%p pio write reg data=0x%"PRIx64" port=0x%"PRIx64" size=%d" --cpu_ioreq_move(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p copy dir=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" --xen_map_resource_ioreq(uint32_t id, void *addr) "id: %u addr: %p" --cpu_ioreq_config_read(void *req, uint32_t sbdf, uint32_t reg, uint32_t size, uint32_t data) "I/O=%p sbdf=0x%x reg=%u size=%u data=0x%x" --cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_t reg, uint32_t size, uint32_t data) "I/O=%p sbdf=0x%x reg=%u size=%u data=0x%x" -- -diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c -index 178f0c68fc..36d87555a9 100644 ---- a/hw/i386/xen/xen-hvm.c -+++ b/hw/i386/xen/xen-hvm.c -@@ -10,43 +10,21 @@ - - #include "qemu/osdep.h" - #include "qemu/units.h" -+#include "qapi/error.h" -+#include "qapi/qapi-commands-migration.h" -+#include "trace.h" - --#include "cpu.h" --#include "hw/pci/pci.h" --#include "hw/pci/pci_host.h" - #include "hw/i386/pc.h" - #include "hw/irq.h" --#include "hw/hw.h" - #include "hw/i386/apic-msidef.h" --#include "hw/xen/xen_common.h" --#include "hw/xen/xen-legacy-backend.h" --#include "hw/xen/xen-bus.h" - #include "hw/xen/xen-x86.h" --#include "qapi/error.h" --#include "qapi/qapi-commands-migration.h" --#include "qemu/error-report.h" --#include "qemu/main-loop.h" - #include "qemu/range.h" --#include "sysemu/runstate.h" --#include "sysemu/sysemu.h" --#include "sysemu/xen.h" --#include "sysemu/xen-mapcache.h" --#include "trace.h" - --#include -+#include "hw/xen/xen-hvm-common.h" -+#include "hw/xen/arch_hvm.h" - #include - --//#define DEBUG_XEN_HVM -- --#ifdef DEBUG_XEN_HVM --#define DPRINTF(fmt, ...) \ -- do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0) --#else --#define DPRINTF(fmt, ...) \ -- do { } while (0) --#endif -- --static MemoryRegion ram_memory, ram_640k, ram_lo, ram_hi; -+static MemoryRegion ram_640k, ram_lo, ram_hi; - static MemoryRegion *framebuffer; - static bool xen_in_migration; - -@@ -75,25 +53,6 @@ typedef struct shared_vmport_iopage shared_vmport_iopage_t; - #endif - static shared_vmport_iopage_t *shared_vmport_page; - --static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i) --{ -- return shared_page->vcpu_ioreq[i].vp_eport; --} --static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vcpu) --{ -- return &shared_page->vcpu_ioreq[vcpu]; --} -- --#define BUFFER_IO_MAX_DELAY 100 -- --typedef struct XenPhysmap { -- hwaddr start_addr; -- ram_addr_t size; -- const char *name; -- hwaddr phys_offset; -- -- QLIST_ENTRY(XenPhysmap) list; --} XenPhysmap; - - static QLIST_HEAD(, XenPhysmap) xen_physmap; - static const XenPhysmap *log_for_dirtybit = NULL; -@@ -102,40 +61,6 @@ static unsigned long *dirty_bitmap = NULL; - static Notifier suspend; - static Notifier wakeup; - --typedef struct XenPciDevice { -- PCIDevice *pci_dev; -- uint32_t sbdf; -- QLIST_ENTRY(XenPciDevice) entry; --} XenPciDevice; -- --typedef struct XenIOState { -- ioservid_t ioservid; -- shared_iopage_t *shared_page; -- buffered_iopage_t *buffered_io_page; -- xenforeignmemory_resource_handle *fres; -- QEMUTimer *buffered_io_timer; -- CPUState **cpu_by_vcpu_id; -- /* the evtchn port for polling the notification, */ -- evtchn_port_t *ioreq_local_port; -- /* evtchn remote and local ports for buffered io */ -- evtchn_port_t bufioreq_remote_port; -- evtchn_port_t bufioreq_local_port; -- /* the evtchn fd for polling */ -- xenevtchn_handle *xce_handle; -- /* which vcpu we are serving */ -- int send_vcpu; -- -- struct xs_handle *xenstore; -- MemoryListener memory_listener; -- MemoryListener io_listener; -- QLIST_HEAD(, XenPciDevice) dev_list; -- DeviceListener device_listener; -- -- Notifier exit; --} XenIOState; -- --#include "hw/xen/arch_hvm.h" -- - /* Xen specific function for piix pci */ - - int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) -@@ -248,42 +173,6 @@ static void xen_ram_init(PCMachineState *pcms, - } - } - --void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, -- Error **errp) --{ -- unsigned long nr_pfn; -- xen_pfn_t *pfn_list; -- int i; -- -- if (runstate_check(RUN_STATE_INMIGRATE)) { -- /* RAM already populated in Xen */ -- fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT -- " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRATE\n", -- __func__, size, ram_addr); -- return; -- } -- -- if (mr == &ram_memory) { -- return; -- } -- -- trace_xen_ram_alloc(ram_addr, size); -- -- nr_pfn = size >> TARGET_PAGE_BITS; -- pfn_list = g_malloc(sizeof (*pfn_list) * nr_pfn); -- -- for (i = 0; i < nr_pfn; i++) { -- pfn_list[i] = (ram_addr >> TARGET_PAGE_BITS) + i; -- } -- -- if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 0, pfn_list)) { -- error_setg(errp, "xen: failed to populate ram at " RAM_ADDR_FMT, -- ram_addr); -- } -- -- g_free(pfn_list); --} -- - static XenPhysmap *get_physmapping(hwaddr start_addr, ram_addr_t size) - { - XenPhysmap *physmap = NULL; -@@ -473,109 +362,6 @@ static int xen_remove_from_physmap(XenIOState *state, - return 0; - } - --static void xen_set_memory(struct MemoryListener *listener, -- MemoryRegionSection *section, -- bool add) --{ -- XenIOState *state = container_of(listener, XenIOState, memory_listener); -- -- if (section->mr == &ram_memory) { -- return; -- } else { -- if (add) { -- xen_map_memory_section(xen_domid, state->ioservid, -- section); -- } else { -- xen_unmap_memory_section(xen_domid, state->ioservid, -- section); -- } -- } -- arch_xen_set_memory(state, section, add); --} -- --static void xen_region_add(MemoryListener *listener, -- MemoryRegionSection *section) --{ -- memory_region_ref(section->mr); -- xen_set_memory(listener, section, true); --} -- --static void xen_region_del(MemoryListener *listener, -- MemoryRegionSection *section) --{ -- xen_set_memory(listener, section, false); -- memory_region_unref(section->mr); --} -- --static void xen_io_add(MemoryListener *listener, -- MemoryRegionSection *section) --{ -- XenIOState *state = container_of(listener, XenIOState, io_listener); -- MemoryRegion *mr = section->mr; -- -- if (mr->ops == &unassigned_io_ops) { -- return; -- } -- -- memory_region_ref(mr); -- -- xen_map_io_section(xen_domid, state->ioservid, section); --} -- --static void xen_io_del(MemoryListener *listener, -- MemoryRegionSection *section) --{ -- XenIOState *state = container_of(listener, XenIOState, io_listener); -- MemoryRegion *mr = section->mr; -- -- if (mr->ops == &unassigned_io_ops) { -- return; -- } -- -- xen_unmap_io_section(xen_domid, state->ioservid, section); -- -- memory_region_unref(mr); --} -- --static void xen_device_realize(DeviceListener *listener, -- DeviceState *dev) --{ -- XenIOState *state = container_of(listener, XenIOState, device_listener); -- -- if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { -- PCIDevice *pci_dev = PCI_DEVICE(dev); -- XenPciDevice *xendev = g_new(XenPciDevice, 1); -- -- xendev->pci_dev = pci_dev; -- xendev->sbdf = PCI_BUILD_BDF(pci_dev_bus_num(pci_dev), -- pci_dev->devfn); -- QLIST_INSERT_HEAD(&state->dev_list, xendev, entry); -- -- xen_map_pcidev(xen_domid, state->ioservid, pci_dev); -- } --} -- --static void xen_device_unrealize(DeviceListener *listener, -- DeviceState *dev) --{ -- XenIOState *state = container_of(listener, XenIOState, device_listener); -- -- if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { -- PCIDevice *pci_dev = PCI_DEVICE(dev); -- XenPciDevice *xendev, *next; -- -- xen_unmap_pcidev(xen_domid, state->ioservid, pci_dev); -- -- QLIST_FOREACH_SAFE(xendev, &state->dev_list, entry, next) { -- if (xendev->pci_dev == pci_dev) { -- QLIST_REMOVE(xendev, entry); -- g_free(xendev); -- break; -- } -- } -- } --} -- - static void xen_sync_dirty_bitmap(XenIOState *state, - hwaddr start_addr, - ram_addr_t size) -@@ -683,277 +469,6 @@ static MemoryListener xen_memory_listener = { - .priority = 10, - }; - --static MemoryListener xen_io_listener = { -- .name = "xen-io", -- .region_add = xen_io_add, -- .region_del = xen_io_del, -- .priority = 10, --}; -- --static DeviceListener xen_device_listener = { -- .realize = xen_device_realize, -- .unrealize = xen_device_unrealize, --}; -- --/* get the ioreq packets from share mem */ --static ioreq_t *cpu_get_ioreq_from_shared_memory(XenIOState *state, int vcpu) --{ -- ioreq_t *req = xen_vcpu_ioreq(state->shared_page, vcpu); -- -- if (req->state != STATE_IOREQ_READY) { -- DPRINTF("I/O request not ready: " -- "%x, ptr: %x, port: %"PRIx64", " -- "data: %"PRIx64", count: %u, size: %u\n", -- req->state, req->data_is_ptr, req->addr, -- req->data, req->count, req->size); -- return NULL; -- } -- -- xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */ -- -- req->state = STATE_IOREQ_INPROCESS; -- return req; --} -- --/* use poll to get the port notification */ --/* ioreq_vec--out,the */ --/* retval--the number of ioreq packet */ --static ioreq_t *cpu_get_ioreq(XenIOState *state) --{ -- MachineState *ms = MACHINE(qdev_get_machine()); -- unsigned int max_cpus = ms->smp.max_cpus; -- int i; -- evtchn_port_t port; -- -- port = xenevtchn_pending(state->xce_handle); -- if (port == state->bufioreq_local_port) { -- timer_mod(state->buffered_io_timer, -- BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); -- return NULL; -- } -- -- if (port != -1) { -- for (i = 0; i < max_cpus; i++) { -- if (state->ioreq_local_port[i] == port) { -- break; -- } -- } -- -- if (i == max_cpus) { -- hw_error("Fatal error while trying to get io event!\n"); -- } -- -- /* unmask the wanted port again */ -- xenevtchn_unmask(state->xce_handle, port); -- -- /* get the io packet from shared memory */ -- state->send_vcpu = i; -- return cpu_get_ioreq_from_shared_memory(state, i); -- } -- -- /* read error or read nothing */ -- return NULL; --} -- --static uint32_t do_inp(uint32_t addr, unsigned long size) --{ -- switch (size) { -- case 1: -- return cpu_inb(addr); -- case 2: -- return cpu_inw(addr); -- case 4: -- return cpu_inl(addr); -- default: -- hw_error("inp: bad size: %04x %lx", addr, size); -- } --} -- --static void do_outp(uint32_t addr, -- unsigned long size, uint32_t val) --{ -- switch (size) { -- case 1: -- return cpu_outb(addr, val); -- case 2: -- return cpu_outw(addr, val); -- case 4: -- return cpu_outl(addr, val); -- default: -- hw_error("outp: bad size: %04x %lx", addr, size); -- } --} -- --/* -- * Helper functions which read/write an object from/to physical guest -- * memory, as part of the implementation of an ioreq. -- * -- * Equivalent to -- * cpu_physical_memory_rw(addr + (req->df ? -1 : +1) * req->size * i, -- * val, req->size, 0/1) -- * except without the integer overflow problems. -- */ --static void rw_phys_req_item(hwaddr addr, -- ioreq_t *req, uint32_t i, void *val, int rw) --{ -- /* Do everything unsigned so overflow just results in a truncated result -- * and accesses to undesired parts of guest memory, which is up -- * to the guest */ -- hwaddr offset = (hwaddr)req->size * i; -- if (req->df) { -- addr -= offset; -- } else { -- addr += offset; -- } -- cpu_physical_memory_rw(addr, val, req->size, rw); --} -- --static inline void read_phys_req_item(hwaddr addr, -- ioreq_t *req, uint32_t i, void *val) --{ -- rw_phys_req_item(addr, req, i, val, 0); --} --static inline void write_phys_req_item(hwaddr addr, -- ioreq_t *req, uint32_t i, void *val) --{ -- rw_phys_req_item(addr, req, i, val, 1); --} -- -- --static void cpu_ioreq_pio(ioreq_t *req) --{ -- uint32_t i; -- -- trace_cpu_ioreq_pio(req, req->dir, req->df, req->data_is_ptr, req->addr, -- req->data, req->count, req->size); -- -- if (req->size > sizeof(uint32_t)) { -- hw_error("PIO: bad size (%u)", req->size); -- } -- -- if (req->dir == IOREQ_READ) { -- if (!req->data_is_ptr) { -- req->data = do_inp(req->addr, req->size); -- trace_cpu_ioreq_pio_read_reg(req, req->data, req->addr, -- req->size); -- } else { -- uint32_t tmp; -- -- for (i = 0; i < req->count; i++) { -- tmp = do_inp(req->addr, req->size); -- write_phys_req_item(req->data, req, i, &tmp); -- } -- } -- } else if (req->dir == IOREQ_WRITE) { -- if (!req->data_is_ptr) { -- trace_cpu_ioreq_pio_write_reg(req, req->data, req->addr, -- req->size); -- do_outp(req->addr, req->size, req->data); -- } else { -- for (i = 0; i < req->count; i++) { -- uint32_t tmp = 0; -- -- read_phys_req_item(req->data, req, i, &tmp); -- do_outp(req->addr, req->size, tmp); -- } -- } -- } --} -- --static void cpu_ioreq_move(ioreq_t *req) --{ -- uint32_t i; -- -- trace_cpu_ioreq_move(req, req->dir, req->df, req->data_is_ptr, req->addr, -- req->data, req->count, req->size); -- -- if (req->size > sizeof(req->data)) { -- hw_error("MMIO: bad size (%u)", req->size); -- } -- -- if (!req->data_is_ptr) { -- if (req->dir == IOREQ_READ) { -- for (i = 0; i < req->count; i++) { -- read_phys_req_item(req->addr, req, i, &req->data); -- } -- } else if (req->dir == IOREQ_WRITE) { -- for (i = 0; i < req->count; i++) { -- write_phys_req_item(req->addr, req, i, &req->data); -- } -- } -- } else { -- uint64_t tmp; -- -- if (req->dir == IOREQ_READ) { -- for (i = 0; i < req->count; i++) { -- read_phys_req_item(req->addr, req, i, &tmp); -- write_phys_req_item(req->data, req, i, &tmp); -- } -- } else if (req->dir == IOREQ_WRITE) { -- for (i = 0; i < req->count; i++) { -- read_phys_req_item(req->data, req, i, &tmp); -- write_phys_req_item(req->addr, req, i, &tmp); -- } -- } -- } --} -- --static void cpu_ioreq_config(XenIOState *state, ioreq_t *req) --{ -- uint32_t sbdf = req->addr >> 32; -- uint32_t reg = req->addr; -- XenPciDevice *xendev; -- -- if (req->size != sizeof(uint8_t) && req->size != sizeof(uint16_t) && -- req->size != sizeof(uint32_t)) { -- hw_error("PCI config access: bad size (%u)", req->size); -- } -- -- if (req->count != 1) { -- hw_error("PCI config access: bad count (%u)", req->count); -- } -- -- QLIST_FOREACH(xendev, &state->dev_list, entry) { -- if (xendev->sbdf != sbdf) { -- continue; -- } -- -- if (!req->data_is_ptr) { -- if (req->dir == IOREQ_READ) { -- req->data = pci_host_config_read_common( -- xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, -- req->size); -- trace_cpu_ioreq_config_read(req, xendev->sbdf, reg, -- req->size, req->data); -- } else if (req->dir == IOREQ_WRITE) { -- trace_cpu_ioreq_config_write(req, xendev->sbdf, reg, -- req->size, req->data); -- pci_host_config_write_common( -- xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, -- req->data, req->size); -- } -- } else { -- uint32_t tmp; -- -- if (req->dir == IOREQ_READ) { -- tmp = pci_host_config_read_common( -- xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, -- req->size); -- trace_cpu_ioreq_config_read(req, xendev->sbdf, reg, -- req->size, tmp); -- write_phys_req_item(req->data, req, 0, &tmp); -- } else if (req->dir == IOREQ_WRITE) { -- read_phys_req_item(req->data, req, 0, &tmp); -- trace_cpu_ioreq_config_write(req, xendev->sbdf, reg, -- req->size, tmp); -- pci_host_config_write_common( -- xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, -- tmp, req->size); -- } -- } -- } --} -- - static void regs_to_cpu(vmware_regs_t *vmport_regs, ioreq_t *req) - { - X86CPU *cpu; -@@ -997,223 +512,6 @@ static void handle_vmport_ioreq(XenIOState *state, ioreq_t *req) - current_cpu = NULL; - } - --static void handle_ioreq(XenIOState *state, ioreq_t *req) --{ -- trace_handle_ioreq(req, req->type, req->dir, req->df, req->data_is_ptr, -- req->addr, req->data, req->count, req->size); -- -- if (!req->data_is_ptr && (req->dir == IOREQ_WRITE) && -- (req->size < sizeof (target_ulong))) { -- req->data &= ((target_ulong) 1 << (8 * req->size)) - 1; -- } -- -- if (req->dir == IOREQ_WRITE) -- trace_handle_ioreq_write(req, req->type, req->df, req->data_is_ptr, -- req->addr, req->data, req->count, req->size); -- -- switch (req->type) { -- case IOREQ_TYPE_PIO: -- cpu_ioreq_pio(req); -- break; -- case IOREQ_TYPE_COPY: -- cpu_ioreq_move(req); -- break; -- case IOREQ_TYPE_TIMEOFFSET: -- break; -- case IOREQ_TYPE_INVALIDATE: -- xen_invalidate_map_cache(); -- break; -- case IOREQ_TYPE_PCI_CONFIG: -- cpu_ioreq_config(state, req); -- break; -- default: -- arch_handle_ioreq(state, req); -- } -- if (req->dir == IOREQ_READ) { -- trace_handle_ioreq_read(req, req->type, req->df, req->data_is_ptr, -- req->addr, req->data, req->count, req->size); -- } --} -- --static bool handle_buffered_iopage(XenIOState *state) --{ -- buffered_iopage_t *buf_page = state->buffered_io_page; -- buf_ioreq_t *buf_req = NULL; -- bool handled_ioreq = false; -- ioreq_t req; -- int qw; -- -- if (!buf_page) { -- return 0; -- } -- -- memset(&req, 0x00, sizeof(req)); -- req.state = STATE_IOREQ_READY; -- req.count = 1; -- req.dir = IOREQ_WRITE; -- -- for (;;) { -- uint32_t rdptr = buf_page->read_pointer, wrptr; -- -- xen_rmb(); -- wrptr = buf_page->write_pointer; -- xen_rmb(); -- if (rdptr != buf_page->read_pointer) { -- continue; -- } -- if (rdptr == wrptr) { -- break; -- } -- buf_req = &buf_page->buf_ioreq[rdptr % IOREQ_BUFFER_SLOT_NUM]; -- req.size = 1U << buf_req->size; -- req.addr = buf_req->addr; -- req.data = buf_req->data; -- req.type = buf_req->type; -- xen_rmb(); -- qw = (req.size == 8); -- if (qw) { -- if (rdptr + 1 == wrptr) { -- hw_error("Incomplete quad word buffered ioreq"); -- } -- buf_req = &buf_page->buf_ioreq[(rdptr + 1) % -- IOREQ_BUFFER_SLOT_NUM]; -- req.data |= ((uint64_t)buf_req->data) << 32; -- xen_rmb(); -- } -- -- handle_ioreq(state, &req); -- -- /* Only req.data may get updated by handle_ioreq(), albeit even that -- * should not happen as such data would never make it to the guest (we -- * can only usefully see writes here after all). -- */ -- assert(req.state == STATE_IOREQ_READY); -- assert(req.count == 1); -- assert(req.dir == IOREQ_WRITE); -- assert(!req.data_is_ptr); -- -- qatomic_add(&buf_page->read_pointer, qw + 1); -- handled_ioreq = true; -- } -- -- return handled_ioreq; --} -- --static void handle_buffered_io(void *opaque) --{ -- XenIOState *state = opaque; -- -- if (handle_buffered_iopage(state)) { -- timer_mod(state->buffered_io_timer, -- BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); -- } else { -- timer_del(state->buffered_io_timer); -- xenevtchn_unmask(state->xce_handle, state->bufioreq_local_port); -- } --} -- --static void cpu_handle_ioreq(void *opaque) --{ -- XenIOState *state = opaque; -- ioreq_t *req = cpu_get_ioreq(state); -- -- handle_buffered_iopage(state); -- if (req) { -- ioreq_t copy = *req; -- -- xen_rmb(); -- handle_ioreq(state, ©); -- req->data = copy.data; -- -- if (req->state != STATE_IOREQ_INPROCESS) { -- fprintf(stderr, "Badness in I/O request ... not in service?!: " -- "%x, ptr: %x, port: %"PRIx64", " -- "data: %"PRIx64", count: %u, size: %u, type: %u\n", -- req->state, req->data_is_ptr, req->addr, -- req->data, req->count, req->size, req->type); -- destroy_hvm_domain(false); -- return; -- } -- -- xen_wmb(); /* Update ioreq contents /then/ update state. */ -- -- /* -- * We do this before we send the response so that the tools -- * have the opportunity to pick up on the reset before the -- * guest resumes and does a hlt with interrupts disabled which -- * causes Xen to powerdown the domain. -- */ -- if (runstate_is_running()) { -- ShutdownCause request; -- -- if (qemu_shutdown_requested_get()) { -- destroy_hvm_domain(false); -- } -- request = qemu_reset_requested_get(); -- if (request) { -- qemu_system_reset(request); -- destroy_hvm_domain(true); -- } -- } -- -- req->state = STATE_IORESP_READY; -- xenevtchn_notify(state->xce_handle, -- state->ioreq_local_port[state->send_vcpu]); -- } --} -- --static void xen_main_loop_prepare(XenIOState *state) --{ -- int evtchn_fd = -1; -- -- if (state->xce_handle != NULL) { -- evtchn_fd = xenevtchn_fd(state->xce_handle); -- } -- -- state->buffered_io_timer = timer_new_ms(QEMU_CLOCK_REALTIME, handle_buffered_io, -- state); -- -- if (evtchn_fd != -1) { -- CPUState *cpu_state; -- -- DPRINTF("%s: Init cpu_by_vcpu_id\n", __func__); -- CPU_FOREACH(cpu_state) { -- DPRINTF("%s: cpu_by_vcpu_id[%d]=%p\n", -- __func__, cpu_state->cpu_index, cpu_state); -- state->cpu_by_vcpu_id[cpu_state->cpu_index] = cpu_state; -- } -- qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state); -- } --} -- -- --static void xen_hvm_change_state_handler(void *opaque, bool running, -- RunState rstate) --{ -- XenIOState *state = opaque; -- -- if (running) { -- xen_main_loop_prepare(state); -- } -- -- xen_set_ioreq_server_state(xen_domid, -- state->ioservid, -- (rstate == RUN_STATE_RUNNING)); --} -- --static void xen_exit_notifier(Notifier *n, void *data) --{ -- XenIOState *state = container_of(n, XenIOState, exit); -- -- xen_destroy_ioreq_server(xen_domid, state->ioservid); -- if (state->fres != NULL) { -- xenforeignmemory_unmap_resource(xen_fmem, state->fres); -- } -- -- xenevtchn_close(state->xce_handle); -- xs_daemon_close(state->xenstore); --} -- - #ifdef XEN_COMPAT_PHYSMAP - static void xen_read_physmap(XenIOState *state) - { -@@ -1273,178 +571,17 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data) - xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); - } - --static int xen_map_ioreq_server(XenIOState *state) --{ -- void *addr = NULL; -- xen_pfn_t ioreq_pfn; -- xen_pfn_t bufioreq_pfn; -- evtchn_port_t bufioreq_evtchn; -- int rc; -- -- /* -- * Attempt to map using the resource API and fall back to normal -- * foreign mapping if this is not supported. -- */ -- QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_bufioreq != 0); -- QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_ioreq(0) != 1); -- state->fres = xenforeignmemory_map_resource(xen_fmem, xen_domid, -- XENMEM_resource_ioreq_server, -- state->ioservid, 0, 2, -- &addr, -- PROT_READ | PROT_WRITE, 0); -- if (state->fres != NULL) { -- trace_xen_map_resource_ioreq(state->ioservid, addr); -- state->buffered_io_page = addr; -- state->shared_page = addr + TARGET_PAGE_SIZE; -- } else if (errno != EOPNOTSUPP) { -- error_report("failed to map ioreq server resources: error %d handle=%p", -- errno, xen_xc); -- return -1; -- } -- -- rc = xen_get_ioreq_server_info(xen_domid, state->ioservid, -- (state->shared_page == NULL) ? -- &ioreq_pfn : NULL, -- (state->buffered_io_page == NULL) ? -- &bufioreq_pfn : NULL, -- &bufioreq_evtchn); -- if (rc < 0) { -- error_report("failed to get ioreq server info: error %d handle=%p", -- errno, xen_xc); -- return rc; -- } -- -- if (state->shared_page == NULL) { -- DPRINTF("shared page at pfn %lx\n", ioreq_pfn); -- -- state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid, -- PROT_READ | PROT_WRITE, -- 1, &ioreq_pfn, NULL); -- if (state->shared_page == NULL) { -- error_report("map shared IO page returned error %d handle=%p", -- errno, xen_xc); -- } -- } -- -- if (state->buffered_io_page == NULL) { -- DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn); -- -- state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid, -- PROT_READ | PROT_WRITE, -- 1, &bufioreq_pfn, -- NULL); -- if (state->buffered_io_page == NULL) { -- error_report("map buffered IO page returned error %d", errno); -- return -1; -- } -- } -- -- if (state->shared_page == NULL || state->buffered_io_page == NULL) { -- return -1; -- } -- -- DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn); -- -- state->bufioreq_remote_port = bufioreq_evtchn; -- -- return 0; --} -- - void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) - { - MachineState *ms = MACHINE(pcms); - unsigned int max_cpus = ms->smp.max_cpus; -- int i, rc; -+ int rc; - xen_pfn_t ioreq_pfn; - XenIOState *state; - - state = g_new0(XenIOState, 1); - -- state->xce_handle = xenevtchn_open(NULL, 0); -- if (state->xce_handle == NULL) { -- perror("xen: event channel open"); -- goto err; -- } -- -- state->xenstore = xs_daemon_open(); -- if (state->xenstore == NULL) { -- perror("xen: xenstore open"); -- goto err; -- } -- -- xen_create_ioreq_server(xen_domid, &state->ioservid); -- -- state->exit.notify = xen_exit_notifier; -- qemu_add_exit_notifier(&state->exit); -- -- /* -- * Register wake-up support in QMP query-current-machine API -- */ -- qemu_register_wakeup_support(); -- -- rc = xen_map_ioreq_server(state); -- if (rc < 0) { -- goto err; -- } -- -- /* Note: cpus is empty at this point in init */ -- state->cpu_by_vcpu_id = g_new0(CPUState *, max_cpus); -- -- rc = xen_set_ioreq_server_state(xen_domid, state->ioservid, true); -- if (rc < 0) { -- error_report("failed to enable ioreq server info: error %d handle=%p", -- errno, xen_xc); -- goto err; -- } -- -- state->ioreq_local_port = g_new0(evtchn_port_t, max_cpus); -- -- /* FIXME: how about if we overflow the page here? */ -- for (i = 0; i < max_cpus; i++) { -- rc = xenevtchn_bind_interdomain(state->xce_handle, xen_domid, -- xen_vcpu_eport(state->shared_page, i)); -- if (rc == -1) { -- error_report("shared evtchn %d bind error %d", i, errno); -- goto err; -- } -- state->ioreq_local_port[i] = rc; -- } -- -- rc = xenevtchn_bind_interdomain(state->xce_handle, xen_domid, -- state->bufioreq_remote_port); -- if (rc == -1) { -- error_report("buffered evtchn bind error %d", errno); -- goto err; -- } -- state->bufioreq_local_port = rc; -- -- /* Init RAM management */ --#ifdef XEN_COMPAT_PHYSMAP -- xen_map_cache_init(xen_phys_offset_to_gaddr, state); --#else -- xen_map_cache_init(NULL, state); --#endif -- -- qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state); -- -- state->memory_listener = xen_memory_listener; -- memory_listener_register(&state->memory_listener, &address_space_memory); -- -- state->io_listener = xen_io_listener; -- memory_listener_register(&state->io_listener, &address_space_io); -- -- state->device_listener = xen_device_listener; -- QLIST_INIT(&state->dev_list); -- device_listener_register(&state->device_listener); -- -- xen_bus_init(); -- -- /* Initialize backend core & drivers */ -- if (xen_be_init() != 0) { -- error_report("xen backend core setup failed"); -- goto err; -- } -- xen_be_register_common(); -+ xen_register_ioreq(state, max_cpus, xen_memory_listener); - - QLIST_INIT(&xen_physmap); - xen_read_physmap(state); -@@ -1484,59 +621,11 @@ err: - exit(1); - } - --void destroy_hvm_domain(bool reboot) --{ -- xc_interface *xc_handle; -- int sts; -- int rc; -- -- unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; -- -- if (xen_dmod) { -- rc = xendevicemodel_shutdown(xen_dmod, xen_domid, reason); -- if (!rc) { -- return; -- } -- if (errno != ENOTTY /* old Xen */) { -- perror("xendevicemodel_shutdown failed"); -- } -- /* well, try the old thing then */ -- } -- -- xc_handle = xc_interface_open(0, 0, 0); -- if (xc_handle == NULL) { -- fprintf(stderr, "Cannot acquire xenctrl handle\n"); -- } else { -- sts = xc_domain_shutdown(xc_handle, xen_domid, reason); -- if (sts != 0) { -- fprintf(stderr, "xc_domain_shutdown failed to issue %s, " -- "sts %d, %s\n", reboot ? "reboot" : "poweroff", -- sts, strerror(errno)); -- } else { -- fprintf(stderr, "Issued domain %d %s\n", xen_domid, -- reboot ? "reboot" : "poweroff"); -- } -- xc_interface_close(xc_handle); -- } --} -- - void xen_register_framebuffer(MemoryRegion *mr) - { - framebuffer = mr; - } - --void xen_shutdown_fatal_error(const char *fmt, ...) --{ -- va_list ap; -- -- va_start(ap, fmt); -- vfprintf(stderr, fmt, ap); -- va_end(ap); -- fprintf(stderr, "Will destroy the domain.\n"); -- /* destroy the domain */ -- qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); --} -- - void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) - { - if (unlikely(xen_in_migration)) { -diff --git a/hw/xen/meson.build b/hw/xen/meson.build -index 19d0637c46..008e036d63 100644 ---- a/hw/xen/meson.build -+++ b/hw/xen/meson.build -@@ -25,4 +25,7 @@ specific_ss.add_all(when: ['CONFIG_XEN', xen], if_true: xen_specific_ss) - - xen_ss = ss.source_set() - --xen_ss.add(when: 'CONFIG_XEN', if_true: files('xen-mapcache.c')) -+xen_ss.add(when: 'CONFIG_XEN', if_true: files( -+ 'xen-mapcache.c', -+ 'xen-hvm-common.c', -+)) -diff --git a/hw/xen/trace-events b/hw/xen/trace-events -index 2c8f238f42..02ca1183da 100644 ---- a/hw/xen/trace-events -+++ b/hw/xen/trace-events -@@ -42,6 +42,20 @@ xs_node_vscanf(char *path, char *value) "%s %s" - xs_node_watch(char *path) "%s" - xs_node_unwatch(char *path) "%s" - -+# xen-hvm.c -+xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: 0x%lx, size 0x%lx" -+xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_dirty) "0x%"PRIx64" size 0x%lx, log_dirty %i" -+handle_ioreq(void *req, uint32_t type, uint32_t dir, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p type=%d dir=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" -+handle_ioreq_read(void *req, uint32_t type, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p read type=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" -+handle_ioreq_write(void *req, uint32_t type, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p write type=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" -+cpu_ioreq_pio(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p pio dir=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" -+cpu_ioreq_pio_read_reg(void *req, uint64_t data, uint64_t addr, uint32_t size) "I/O=%p pio read reg data=0x%"PRIx64" port=0x%"PRIx64" size=%d" -+cpu_ioreq_pio_write_reg(void *req, uint64_t data, uint64_t addr, uint32_t size) "I/O=%p pio write reg data=0x%"PRIx64" port=0x%"PRIx64" size=%d" -+cpu_ioreq_move(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p copy dir=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" -+xen_map_resource_ioreq(uint32_t id, void *addr) "id: %u addr: %p" -+cpu_ioreq_config_read(void *req, uint32_t sbdf, uint32_t reg, uint32_t size, uint32_t data) "I/O=%p sbdf=0x%x reg=%u size=%u data=0x%x" -+cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_t reg, uint32_t size, uint32_t data) "I/O=%p sbdf=0x%x reg=%u size=%u data=0x%x" -+ - # xen-mapcache.c - xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 - xen_remap_bucket(uint64_t index) "index 0x%"PRIx64 -diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c -new file mode 100644 -index 0000000000..67f76f6010 ---- /dev/null -+++ b/hw/xen/xen-hvm-common.c -@@ -0,0 +1,861 @@ -+#include "qemu/osdep.h" -+#include "qemu/units.h" -+#include "qapi/error.h" -+#include "trace.h" -+ -+#include "hw/pci/pci_host.h" -+#include "hw/xen/xen-hvm-common.h" -+#include "hw/xen/xen-legacy-backend.h" -+#include "hw/xen/xen-bus.h" -+#include "hw/boards.h" -+#include "hw/xen/arch_hvm.h" -+ -+MemoryRegion ram_memory; -+ -+MemoryListener xen_io_listener = { -+ .name = "xen-io", -+ .region_add = xen_io_add, -+ .region_del = xen_io_del, -+ .priority = 10, -+}; -+ -+DeviceListener xen_device_listener = { -+ .realize = xen_device_realize, -+ .unrealize = xen_device_unrealize, -+}; -+ -+static void xen_set_memory(struct MemoryListener *listener, -+ MemoryRegionSection *section, -+ bool add) -+{ -+ XenIOState *state = container_of(listener, XenIOState, memory_listener); -+ -+ if (section->mr == &ram_memory) { -+ return; -+ } else { -+ if (add) { -+ xen_map_memory_section(xen_domid, state->ioservid, -+ section); -+ } else { -+ xen_unmap_memory_section(xen_domid, state->ioservid, -+ section); -+ } -+ } -+ arch_xen_set_memory(state, section, add); -+} -+ -+void xen_region_add(MemoryListener *listener, -+ MemoryRegionSection *section) -+{ -+ memory_region_ref(section->mr); -+ xen_set_memory(listener, section, true); -+} -+ -+void xen_region_del(MemoryListener *listener, -+ MemoryRegionSection *section) -+{ -+ xen_set_memory(listener, section, false); -+ memory_region_unref(section->mr); -+} -+ -+void xen_io_add(MemoryListener *listener, -+ MemoryRegionSection *section) -+{ -+ XenIOState *state = container_of(listener, XenIOState, io_listener); -+ MemoryRegion *mr = section->mr; -+ -+ if (mr->ops == &unassigned_io_ops) { -+ return; -+ } -+ -+ memory_region_ref(mr); -+ -+ xen_map_io_section(xen_domid, state->ioservid, section); -+} -+ -+void xen_io_del(MemoryListener *listener, -+ MemoryRegionSection *section) -+{ -+ XenIOState *state = container_of(listener, XenIOState, io_listener); -+ MemoryRegion *mr = section->mr; -+ -+ if (mr->ops == &unassigned_io_ops) { -+ return; -+ } -+ -+ xen_unmap_io_section(xen_domid, state->ioservid, section); -+ -+ memory_region_unref(mr); -+} -+ -+void xen_device_realize(DeviceListener *listener, -+ DeviceState *dev) -+{ -+ XenIOState *state = container_of(listener, XenIOState, device_listener); -+ -+ if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { -+ PCIDevice *pci_dev = PCI_DEVICE(dev); -+ XenPciDevice *xendev = g_new(XenPciDevice, 1); -+ -+ xendev->pci_dev = pci_dev; -+ xendev->sbdf = PCI_BUILD_BDF(pci_dev_bus_num(pci_dev), -+ pci_dev->devfn); -+ QLIST_INSERT_HEAD(&state->dev_list, xendev, entry); -+ -+ xen_map_pcidev(xen_domid, state->ioservid, pci_dev); -+ } -+} -+ -+void xen_device_unrealize(DeviceListener *listener, -+ DeviceState *dev) -+{ -+ XenIOState *state = container_of(listener, XenIOState, device_listener); -+ -+ if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { -+ PCIDevice *pci_dev = PCI_DEVICE(dev); -+ XenPciDevice *xendev, *next; -+ -+ xen_unmap_pcidev(xen_domid, state->ioservid, pci_dev); -+ -+ QLIST_FOREACH_SAFE(xendev, &state->dev_list, entry, next) { -+ if (xendev->pci_dev == pci_dev) { -+ QLIST_REMOVE(xendev, entry); -+ g_free(xendev); -+ break; -+ } -+ } -+ } -+} -+ -+/* get the ioreq packets from share mem */ -+static ioreq_t *cpu_get_ioreq_from_shared_memory(XenIOState *state, int vcpu) -+{ -+ ioreq_t *req = xen_vcpu_ioreq(state->shared_page, vcpu); -+ -+ if (req->state != STATE_IOREQ_READY) { -+ DPRINTF("I/O request not ready: " -+ "%x, ptr: %x, port: %"PRIx64", " -+ "data: %"PRIx64", count: %u, size: %u\n", -+ req->state, req->data_is_ptr, req->addr, -+ req->data, req->count, req->size); -+ return NULL; -+ } -+ -+ xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */ -+ -+ req->state = STATE_IOREQ_INPROCESS; -+ return req; -+} -+ -+/* use poll to get the port notification */ -+/* ioreq_vec--out,the */ -+/* retval--the number of ioreq packet */ -+static ioreq_t *cpu_get_ioreq(XenIOState *state) -+{ -+ MachineState *ms = MACHINE(qdev_get_machine()); -+ unsigned int max_cpus = ms->smp.max_cpus; -+ int i; -+ evtchn_port_t port; -+ -+ port = xenevtchn_pending(state->xce_handle); -+ if (port == state->bufioreq_local_port) { -+ timer_mod(state->buffered_io_timer, -+ BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); -+ return NULL; -+ } -+ -+ if (port != -1) { -+ for (i = 0; i < max_cpus; i++) { -+ if (state->ioreq_local_port[i] == port) { -+ break; -+ } -+ } -+ -+ if (i == max_cpus) { -+ hw_error("Fatal error while trying to get io event!\n"); -+ } -+ -+ /* unmask the wanted port again */ -+ xenevtchn_unmask(state->xce_handle, port); -+ -+ /* get the io packet from shared memory */ -+ state->send_vcpu = i; -+ return cpu_get_ioreq_from_shared_memory(state, i); -+ } -+ -+ /* read error or read nothing */ -+ return NULL; -+} -+ -+static uint32_t do_inp(uint32_t addr, unsigned long size) -+{ -+ switch (size) { -+ case 1: -+ return cpu_inb(addr); -+ case 2: -+ return cpu_inw(addr); -+ case 4: -+ return cpu_inl(addr); -+ default: -+ hw_error("inp: bad size: %04x %lx", addr, size); -+ } -+} -+ -+static void do_outp(uint32_t addr, -+ unsigned long size, uint32_t val) -+{ -+ switch (size) { -+ case 1: -+ return cpu_outb(addr, val); -+ case 2: -+ return cpu_outw(addr, val); -+ case 4: -+ return cpu_outl(addr, val); -+ default: -+ hw_error("outp: bad size: %04x %lx", addr, size); -+ } -+} -+ -+/* -+ * Helper functions which read/write an object from/to physical guest -+ * memory, as part of the implementation of an ioreq. -+ * -+ * Equivalent to -+ * cpu_physical_memory_rw(addr + (req->df ? -1 : +1) * req->size * i, -+ * val, req->size, 0/1) -+ * except without the integer overflow problems. -+ */ -+static void rw_phys_req_item(hwaddr addr, -+ ioreq_t *req, uint32_t i, void *val, int rw) -+{ -+ /* Do everything unsigned so overflow just results in a truncated result -+ * and accesses to undesired parts of guest memory, which is up -+ * to the guest */ -+ hwaddr offset = (hwaddr)req->size * i; -+ if (req->df) { -+ addr -= offset; -+ } else { -+ addr += offset; -+ } -+ cpu_physical_memory_rw(addr, val, req->size, rw); -+} -+ -+static inline void read_phys_req_item(hwaddr addr, -+ ioreq_t *req, uint32_t i, void *val) -+{ -+ rw_phys_req_item(addr, req, i, val, 0); -+} -+static inline void write_phys_req_item(hwaddr addr, -+ ioreq_t *req, uint32_t i, void *val) -+{ -+ rw_phys_req_item(addr, req, i, val, 1); -+} -+ -+ -+void cpu_ioreq_pio(ioreq_t *req) -+{ -+ uint32_t i; -+ -+ trace_cpu_ioreq_pio(req, req->dir, req->df, req->data_is_ptr, req->addr, -+ req->data, req->count, req->size); -+ -+ if (req->size > sizeof(uint32_t)) { -+ hw_error("PIO: bad size (%u)", req->size); -+ } -+ -+ if (req->dir == IOREQ_READ) { -+ if (!req->data_is_ptr) { -+ req->data = do_inp(req->addr, req->size); -+ trace_cpu_ioreq_pio_read_reg(req, req->data, req->addr, -+ req->size); -+ } else { -+ uint32_t tmp; -+ -+ for (i = 0; i < req->count; i++) { -+ tmp = do_inp(req->addr, req->size); -+ write_phys_req_item(req->data, req, i, &tmp); -+ } -+ } -+ } else if (req->dir == IOREQ_WRITE) { -+ if (!req->data_is_ptr) { -+ trace_cpu_ioreq_pio_write_reg(req, req->data, req->addr, -+ req->size); -+ do_outp(req->addr, req->size, req->data); -+ } else { -+ for (i = 0; i < req->count; i++) { -+ uint32_t tmp = 0; -+ -+ read_phys_req_item(req->data, req, i, &tmp); -+ do_outp(req->addr, req->size, tmp); -+ } -+ } -+ } -+} -+ -+static void cpu_ioreq_move(ioreq_t *req) -+{ -+ uint32_t i; -+ -+ trace_cpu_ioreq_move(req, req->dir, req->df, req->data_is_ptr, req->addr, -+ req->data, req->count, req->size); -+ -+ if (req->size > sizeof(req->data)) { -+ hw_error("MMIO: bad size (%u)", req->size); -+ } -+ -+ if (!req->data_is_ptr) { -+ if (req->dir == IOREQ_READ) { -+ for (i = 0; i < req->count; i++) { -+ read_phys_req_item(req->addr, req, i, &req->data); -+ } -+ } else if (req->dir == IOREQ_WRITE) { -+ for (i = 0; i < req->count; i++) { -+ write_phys_req_item(req->addr, req, i, &req->data); -+ } -+ } -+ } else { -+ uint64_t tmp; -+ -+ if (req->dir == IOREQ_READ) { -+ for (i = 0; i < req->count; i++) { -+ read_phys_req_item(req->addr, req, i, &tmp); -+ write_phys_req_item(req->data, req, i, &tmp); -+ } -+ } else if (req->dir == IOREQ_WRITE) { -+ for (i = 0; i < req->count; i++) { -+ read_phys_req_item(req->data, req, i, &tmp); -+ write_phys_req_item(req->addr, req, i, &tmp); -+ } -+ } -+ } -+} -+ -+static void cpu_ioreq_config(XenIOState *state, ioreq_t *req) -+{ -+ uint32_t sbdf = req->addr >> 32; -+ uint32_t reg = req->addr; -+ XenPciDevice *xendev; -+ -+ if (req->size != sizeof(uint8_t) && req->size != sizeof(uint16_t) && -+ req->size != sizeof(uint32_t)) { -+ hw_error("PCI config access: bad size (%u)", req->size); -+ } -+ -+ if (req->count != 1) { -+ hw_error("PCI config access: bad count (%u)", req->count); -+ } -+ -+ QLIST_FOREACH(xendev, &state->dev_list, entry) { -+ if (xendev->sbdf != sbdf) { -+ continue; -+ } -+ -+ if (!req->data_is_ptr) { -+ if (req->dir == IOREQ_READ) { -+ req->data = pci_host_config_read_common( -+ xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, -+ req->size); -+ trace_cpu_ioreq_config_read(req, xendev->sbdf, reg, -+ req->size, req->data); -+ } else if (req->dir == IOREQ_WRITE) { -+ trace_cpu_ioreq_config_write(req, xendev->sbdf, reg, -+ req->size, req->data); -+ pci_host_config_write_common( -+ xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, -+ req->data, req->size); -+ } -+ } else { -+ uint32_t tmp; -+ -+ if (req->dir == IOREQ_READ) { -+ tmp = pci_host_config_read_common( -+ xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, -+ req->size); -+ trace_cpu_ioreq_config_read(req, xendev->sbdf, reg, -+ req->size, tmp); -+ write_phys_req_item(req->data, req, 0, &tmp); -+ } else if (req->dir == IOREQ_WRITE) { -+ read_phys_req_item(req->data, req, 0, &tmp); -+ trace_cpu_ioreq_config_write(req, xendev->sbdf, reg, -+ req->size, tmp); -+ pci_host_config_write_common( -+ xendev->pci_dev, reg, PCI_CONFIG_SPACE_SIZE, -+ tmp, req->size); -+ } -+ } -+ } -+} -+ -+static void handle_ioreq(XenIOState *state, ioreq_t *req) -+{ -+ trace_handle_ioreq(req, req->type, req->dir, req->df, req->data_is_ptr, -+ req->addr, req->data, req->count, req->size); -+ -+ if (!req->data_is_ptr && (req->dir == IOREQ_WRITE) && -+ (req->size < sizeof (target_ulong))) { -+ req->data &= ((target_ulong) 1 << (8 * req->size)) - 1; -+ } -+ -+ if (req->dir == IOREQ_WRITE) -+ trace_handle_ioreq_write(req, req->type, req->df, req->data_is_ptr, -+ req->addr, req->data, req->count, req->size); -+ -+ switch (req->type) { -+ case IOREQ_TYPE_PIO: -+ cpu_ioreq_pio(req); -+ break; -+ case IOREQ_TYPE_COPY: -+ cpu_ioreq_move(req); -+ break; -+ case IOREQ_TYPE_TIMEOFFSET: -+ break; -+ case IOREQ_TYPE_INVALIDATE: -+ xen_invalidate_map_cache(); -+ break; -+ case IOREQ_TYPE_PCI_CONFIG: -+ cpu_ioreq_config(state, req); -+ break; -+ default: -+ arch_handle_ioreq(state, req); -+ } -+ if (req->dir == IOREQ_READ) { -+ trace_handle_ioreq_read(req, req->type, req->df, req->data_is_ptr, -+ req->addr, req->data, req->count, req->size); -+ } -+} -+ -+static bool handle_buffered_iopage(XenIOState *state) -+{ -+ buffered_iopage_t *buf_page = state->buffered_io_page; -+ buf_ioreq_t *buf_req = NULL; -+ bool handled_ioreq = false; -+ ioreq_t req; -+ int qw; -+ -+ if (!buf_page) { -+ return 0; -+ } -+ -+ memset(&req, 0x00, sizeof(req)); -+ req.state = STATE_IOREQ_READY; -+ req.count = 1; -+ req.dir = IOREQ_WRITE; -+ -+ for (;;) { -+ uint32_t rdptr = buf_page->read_pointer, wrptr; -+ -+ xen_rmb(); -+ wrptr = buf_page->write_pointer; -+ xen_rmb(); -+ if (rdptr != buf_page->read_pointer) { -+ continue; -+ } -+ if (rdptr == wrptr) { -+ break; -+ } -+ buf_req = &buf_page->buf_ioreq[rdptr % IOREQ_BUFFER_SLOT_NUM]; -+ req.size = 1U << buf_req->size; -+ req.addr = buf_req->addr; -+ req.data = buf_req->data; -+ req.type = buf_req->type; -+ xen_rmb(); -+ qw = (req.size == 8); -+ if (qw) { -+ if (rdptr + 1 == wrptr) { -+ hw_error("Incomplete quad word buffered ioreq"); -+ } -+ buf_req = &buf_page->buf_ioreq[(rdptr + 1) % -+ IOREQ_BUFFER_SLOT_NUM]; -+ req.data |= ((uint64_t)buf_req->data) << 32; -+ xen_rmb(); -+ } -+ -+ handle_ioreq(state, &req); -+ -+ /* Only req.data may get updated by handle_ioreq(), albeit even that -+ * should not happen as such data would never make it to the guest (we -+ * can only usefully see writes here after all). -+ */ -+ assert(req.state == STATE_IOREQ_READY); -+ assert(req.count == 1); -+ assert(req.dir == IOREQ_WRITE); -+ assert(!req.data_is_ptr); -+ -+ qatomic_add(&buf_page->read_pointer, qw + 1); -+ } -+ -+ return handled_ioreq; -+} -+ -+static void handle_buffered_io(void *opaque) -+{ -+ XenIOState *state = opaque; -+ -+ if (handle_buffered_iopage(state)) { -+ timer_mod(state->buffered_io_timer, -+ BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); -+ } else { -+ timer_del(state->buffered_io_timer); -+ xenevtchn_unmask(state->xce_handle, state->bufioreq_local_port); -+ } -+} -+ -+static void cpu_handle_ioreq(void *opaque) -+{ -+ XenIOState *state = opaque; -+ ioreq_t *req = cpu_get_ioreq(state); -+ -+ handle_buffered_iopage(state); -+ if (req) { -+ ioreq_t copy = *req; -+ -+ xen_rmb(); -+ handle_ioreq(state, ©); -+ req->data = copy.data; -+ -+ if (req->state != STATE_IOREQ_INPROCESS) { -+ fprintf(stderr, "Badness in I/O request ... not in service?!: " -+ "%x, ptr: %x, port: %"PRIx64", " -+ "data: %"PRIx64", count: %u, size: %u, type: %u\n", -+ req->state, req->data_is_ptr, req->addr, -+ req->data, req->count, req->size, req->type); -+ destroy_hvm_domain(false); -+ return; -+ } -+ -+ xen_wmb(); /* Update ioreq contents /then/ update state. */ -+ -+ /* -+ * We do this before we send the response so that the tools -+ * have the opportunity to pick up on the reset before the -+ * guest resumes and does a hlt with interrupts disabled which -+ * causes Xen to powerdown the domain. -+ */ -+ if (runstate_is_running()) { -+ ShutdownCause request; -+ -+ if (qemu_shutdown_requested_get()) { -+ destroy_hvm_domain(false); -+ } -+ request = qemu_reset_requested_get(); -+ if (request) { -+ qemu_system_reset(request); -+ destroy_hvm_domain(true); -+ } -+ } -+ -+ req->state = STATE_IORESP_READY; -+ xenevtchn_notify(state->xce_handle, -+ state->ioreq_local_port[state->send_vcpu]); -+ } -+} -+ -+static void xen_main_loop_prepare(XenIOState *state) -+{ -+ int evtchn_fd = -1; -+ -+ if (state->xce_handle != NULL) { -+ evtchn_fd = xenevtchn_fd(state->xce_handle); -+ } -+ -+ state->buffered_io_timer = timer_new_ms(QEMU_CLOCK_REALTIME, handle_buffered_io, -+ state); -+ -+ if (evtchn_fd != -1) { -+ CPUState *cpu_state; -+ -+ DPRINTF("%s: Init cpu_by_vcpu_id\n", __func__); -+ CPU_FOREACH(cpu_state) { -+ DPRINTF("%s: cpu_by_vcpu_id[%d]=%p\n", -+ __func__, cpu_state->cpu_index, cpu_state); -+ state->cpu_by_vcpu_id[cpu_state->cpu_index] = cpu_state; -+ } -+ qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state); -+ } -+} -+ -+ -+void xen_hvm_change_state_handler(void *opaque, bool running, -+ RunState rstate) -+{ -+ XenIOState *state = opaque; -+ -+ if (running) { -+ xen_main_loop_prepare(state); -+ } -+ -+ xen_set_ioreq_server_state(xen_domid, -+ state->ioservid, -+ (rstate == RUN_STATE_RUNNING)); -+} -+ -+void xen_exit_notifier(Notifier *n, void *data) -+{ -+ XenIOState *state = container_of(n, XenIOState, exit); -+ -+ xen_destroy_ioreq_server(xen_domid, state->ioservid); -+ if (state->fres != NULL) { -+ xenforeignmemory_unmap_resource(xen_fmem, state->fres); -+ } -+ -+ xenevtchn_close(state->xce_handle); -+ xs_daemon_close(state->xenstore); -+} -+ -+static int xen_map_ioreq_server(XenIOState *state) -+{ -+ void *addr = NULL; -+ xen_pfn_t ioreq_pfn; -+ xen_pfn_t bufioreq_pfn; -+ evtchn_port_t bufioreq_evtchn; -+ int rc; -+ -+ /* -+ * Attempt to map using the resource API and fall back to normal -+ * foreign mapping if this is not supported. -+ */ -+ QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_bufioreq != 0); -+ QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_ioreq(0) != 1); -+ state->fres = xenforeignmemory_map_resource(xen_fmem, xen_domid, -+ XENMEM_resource_ioreq_server, -+ state->ioservid, 0, 2, -+ &addr, -+ PROT_READ | PROT_WRITE, 0); -+ if (state->fres != NULL) { -+ trace_xen_map_resource_ioreq(state->ioservid, addr); -+ state->buffered_io_page = addr; -+ state->shared_page = addr + TARGET_PAGE_SIZE; -+ } else if (errno != EOPNOTSUPP) { -+ error_report("failed to map ioreq server resources: error %d handle=%p", -+ errno, xen_xc); -+ return -1; -+ } -+ -+ rc = xen_get_ioreq_server_info(xen_domid, state->ioservid, -+ (state->shared_page == NULL) ? -+ &ioreq_pfn : NULL, -+ (state->buffered_io_page == NULL) ? -+ &bufioreq_pfn : NULL, -+ &bufioreq_evtchn); -+ if (rc < 0) { -+ error_report("failed to get ioreq server info: error %d handle=%p", -+ errno, xen_xc); -+ return rc; -+ } -+ -+ if (state->shared_page == NULL) { -+ DPRINTF("shared page at pfn %lx\n", ioreq_pfn); -+ -+ state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid, -+ PROT_READ | PROT_WRITE, -+ 1, &ioreq_pfn, NULL); -+ if (state->shared_page == NULL) { -+ error_report("map shared IO page returned error %d handle=%p", -+ errno, xen_xc); -+ } -+ } -+ -+ if (state->buffered_io_page == NULL) { -+ DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn); -+ -+ state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid, -+ PROT_READ | PROT_WRITE, -+ 1, &bufioreq_pfn, -+ NULL); -+ if (state->buffered_io_page == NULL) { -+ error_report("map buffered IO page returned error %d", errno); -+ return -1; -+ } -+ } -+ -+ if (state->shared_page == NULL || state->buffered_io_page == NULL) { -+ return -1; -+ } -+ -+ DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn); -+ -+ state->bufioreq_remote_port = bufioreq_evtchn; -+ -+ return 0; -+} -+ -+void xen_shutdown_fatal_error(const char *fmt, ...) -+{ -+ va_list ap; -+ -+ va_start(ap, fmt); -+ vfprintf(stderr, fmt, ap); -+ va_end(ap); -+ fprintf(stderr, "Will destroy the domain.\n"); -+ /* destroy the domain */ -+ qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); -+} -+ -+void destroy_hvm_domain(bool reboot) -+{ -+ xc_interface *xc_handle; -+ int sts; -+ int rc; -+ -+ unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; -+ -+ if (xen_dmod) { -+ rc = xendevicemodel_shutdown(xen_dmod, xen_domid, reason); -+ if (!rc) { -+ return; -+ } -+ if (errno != ENOTTY /* old Xen */) { -+ perror("xendevicemodel_shutdown failed"); -+ } -+ /* well, try the old thing then */ -+ } -+ -+ xc_handle = xc_interface_open(0, 0, 0); -+ if (xc_handle == NULL) { -+ fprintf(stderr, "Cannot acquire xenctrl handle\n"); -+ } else { -+ sts = xc_domain_shutdown(xc_handle, xen_domid, reason); -+ if (sts != 0) { -+ fprintf(stderr, "xc_domain_shutdown failed to issue %s, " -+ "sts %d, %s\n", reboot ? "reboot" : "poweroff", -+ sts, strerror(errno)); -+ } else { -+ fprintf(stderr, "Issued domain %d %s\n", xen_domid, -+ reboot ? "reboot" : "poweroff"); -+ } -+ xc_interface_close(xc_handle); -+ } -+} -+ -+void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, -+ Error **errp) -+{ -+ unsigned long nr_pfn; -+ xen_pfn_t *pfn_list; -+ int i; -+ -+ if (runstate_check(RUN_STATE_INMIGRATE)) { -+ /* RAM already populated in Xen */ -+ fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT -+ " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRATE\n", -+ __func__, size, ram_addr); -+ return; -+ } -+ -+ if (mr == &ram_memory) { -+ return; -+ } -+ -+ trace_xen_ram_alloc(ram_addr, size); -+ -+ nr_pfn = size >> TARGET_PAGE_BITS; -+ pfn_list = g_malloc(sizeof (*pfn_list) * nr_pfn); -+ -+ for (i = 0; i < nr_pfn; i++) { -+ pfn_list[i] = (ram_addr >> TARGET_PAGE_BITS) + i; -+ } -+ -+ if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 0, pfn_list)) { -+ error_setg(errp, "xen: failed to populate ram at " RAM_ADDR_FMT, -+ ram_addr); -+ } -+ -+ g_free(pfn_list); -+} -+ -+void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, -+ MemoryListener xen_memory_listener) -+{ -+ int i, rc; -+ -+ state->xce_handle = xenevtchn_open(NULL, 0); -+ if (state->xce_handle == NULL) { -+ perror("xen: event channel open"); -+ goto err; -+ } -+ -+ state->xenstore = xs_daemon_open(); -+ if (state->xenstore == NULL) { -+ perror("xen: xenstore open"); -+ goto err; -+ } -+ -+ xen_create_ioreq_server(xen_domid, &state->ioservid); -+ -+ state->exit.notify = xen_exit_notifier; -+ qemu_add_exit_notifier(&state->exit); -+ -+ /* -+ * Register wake-up support in QMP query-current-machine API -+ */ -+ qemu_register_wakeup_support(); -+ -+ rc = xen_map_ioreq_server(state); -+ if (rc < 0) { -+ goto err; -+ } -+ -+ /* Note: cpus is empty at this point in init */ -+ state->cpu_by_vcpu_id = g_new0(CPUState *, max_cpus); -+ -+ rc = xen_set_ioreq_server_state(xen_domid, state->ioservid, true); -+ if (rc < 0) { -+ error_report("failed to enable ioreq server info: error %d handle=%p", -+ errno, xen_xc); -+ goto err; -+ } -+ -+ state->ioreq_local_port = g_new0(evtchn_port_t, max_cpus); -+ -+ /* FIXME: how about if we overflow the page here? */ -+ for (i = 0; i < max_cpus; i++) { -+ rc = xenevtchn_bind_interdomain(state->xce_handle, xen_domid, -+ xen_vcpu_eport(state->shared_page, i)); -+ if (rc == -1) { -+ error_report("shared evtchn %d bind error %d", i, errno); -+ goto err; -+ } -+ state->ioreq_local_port[i] = rc; -+ } -+ -+ rc = xenevtchn_bind_interdomain(state->xce_handle, xen_domid, -+ state->bufioreq_remote_port); -+ if (rc == -1) { -+ error_report("buffered evtchn bind error %d", errno); -+ goto err; -+ } -+ state->bufioreq_local_port = rc; -+ -+ /* Init RAM management */ -+#ifdef XEN_COMPAT_PHYSMAP -+ xen_map_cache_init(xen_phys_offset_to_gaddr, state); -+#else -+ xen_map_cache_init(NULL, state); -+#endif -+ -+ qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state); -+ -+ state->memory_listener = xen_memory_listener; -+ memory_listener_register(&state->memory_listener, &address_space_memory); -+ -+ state->io_listener = xen_io_listener; -+ memory_listener_register(&state->io_listener, &address_space_io); -+ -+ state->device_listener = xen_device_listener; -+ QLIST_INIT(&state->dev_list); -+ device_listener_register(&state->device_listener); -+ -+ xen_bus_init(); -+ -+ /* Initialize backend core & drivers */ -+ if (xen_be_init() != 0) { -+ error_report("xen backend core setup failed"); -+ goto err; -+ } -+ xen_be_register_common(); -+ -+ return; -+err: -+ error_report("xen hardware virtual machine initialisation failed"); -+ exit(1); -+} -diff --git a/include/hw/i386/xen_arch_hvm.h b/include/hw/i386/xen_arch_hvm.h -index 1b2c71ba4f..1000f8f543 100644 ---- a/include/hw/i386/xen_arch_hvm.h -+++ b/include/hw/i386/xen_arch_hvm.h -@@ -2,6 +2,7 @@ - #define HW_XEN_ARCH_I386_HVM_H - - #include -+#include "hw/xen/xen-hvm-common.h" - - void arch_handle_ioreq(XenIOState *state, ioreq_t *req); - void arch_xen_set_memory(XenIOState *state, -diff --git a/include/hw/xen/xen-hvm-common.h b/include/hw/xen/xen-hvm-common.h -new file mode 100644 -index 0000000000..2979f84ee2 ---- /dev/null -+++ b/include/hw/xen/xen-hvm-common.h -@@ -0,0 +1,98 @@ -+#ifndef HW_XEN_HVM_COMMON_H -+#define HW_XEN_HVM_COMMON_H -+ -+#include "qemu/osdep.h" -+#include "qemu/units.h" -+ -+#include "cpu.h" -+#include "hw/pci/pci.h" -+#include "hw/hw.h" -+#include "hw/xen/xen_common.h" -+#include "sysemu/runstate.h" -+#include "sysemu/sysemu.h" -+#include "sysemu/xen.h" -+#include "sysemu/xen-mapcache.h" -+ -+#include -+ -+extern MemoryRegion ram_memory; -+extern MemoryListener xen_io_listener; -+extern DeviceListener xen_device_listener; -+ -+//#define DEBUG_XEN_HVM -+ -+#ifdef DEBUG_XEN_HVM -+#define DPRINTF(fmt, ...) \ -+ do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0) -+#else -+#define DPRINTF(fmt, ...) \ -+ do { } while (0) -+#endif -+ -+static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i) -+{ -+ return shared_page->vcpu_ioreq[i].vp_eport; -+} -+static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vcpu) -+{ -+ return &shared_page->vcpu_ioreq[vcpu]; -+} -+ -+#define BUFFER_IO_MAX_DELAY 100 -+ -+typedef struct XenPhysmap { -+ hwaddr start_addr; -+ ram_addr_t size; -+ const char *name; -+ hwaddr phys_offset; -+ -+ QLIST_ENTRY(XenPhysmap) list; -+} XenPhysmap; -+ -+typedef struct XenPciDevice { -+ PCIDevice *pci_dev; -+ uint32_t sbdf; -+ QLIST_ENTRY(XenPciDevice) entry; -+} XenPciDevice; -+ -+typedef struct XenIOState { -+ ioservid_t ioservid; -+ shared_iopage_t *shared_page; -+ buffered_iopage_t *buffered_io_page; -+ xenforeignmemory_resource_handle *fres; -+ QEMUTimer *buffered_io_timer; -+ CPUState **cpu_by_vcpu_id; -+ /* the evtchn port for polling the notification, */ -+ evtchn_port_t *ioreq_local_port; -+ /* evtchn remote and local ports for buffered io */ -+ evtchn_port_t bufioreq_remote_port; -+ evtchn_port_t bufioreq_local_port; -+ /* the evtchn fd for polling */ -+ xenevtchn_handle *xce_handle; -+ /* which vcpu we are serving */ -+ int send_vcpu; -+ -+ struct xs_handle *xenstore; -+ MemoryListener memory_listener; -+ MemoryListener io_listener; -+ QLIST_HEAD(, XenPciDevice) dev_list; -+ DeviceListener device_listener; -+ -+ Notifier exit; -+} XenIOState; -+ -+void xen_exit_notifier(Notifier *n, void *data); -+ -+void xen_region_add(MemoryListener *listener, MemoryRegionSection *section); -+void xen_region_del(MemoryListener *listener, MemoryRegionSection *section); -+void xen_io_add(MemoryListener *listener, MemoryRegionSection *section); -+void xen_io_del(MemoryListener *listener, MemoryRegionSection *section); -+void xen_device_realize(DeviceListener *listener, DeviceState *dev); -+void xen_device_unrealize(DeviceListener *listener, DeviceState *dev); -+ -+void xen_hvm_change_state_handler(void *opaque, bool running, RunState rstate); -+void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, -+ MemoryListener xen_memory_listener); -+ -+void cpu_ioreq_pio(ioreq_t *req); -+#endif /* HW_XEN_HVM_COMMON_H */ --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0007-xen-mapcache-Fix-build-on-Arm.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0007-xen-mapcache-Fix-build-on-Arm.patch deleted file mode 100644 index 7ff202ff..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0007-xen-mapcache-Fix-build-on-Arm.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 2aca3ff63a5d5897cd32e0030569623f0c454f2c Mon Sep 17 00:00:00 2001 -From: Oleksandr Tyshchenko -Date: Mon, 19 Sep 2022 21:59:55 +0300 -Subject: [PATCH 7/8] xen-mapcache: Fix build on Arm -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -../hw/xen/xen-mapcache.c: In function ‘xen_map_grant_dyn’: -../hw/xen/xen-mapcache.c:668:9: error: ‘refs’ may be used uninitialized - in this function [-Werror=maybe-uninitialized] - 668 | g_free(refs); - | ^~~~~~~~~~~~ -cc1: all warnings being treated as errors - -Signed-off-by: Oleksandr Tyshchenko -Acked-by: Stefano Stabellini ---- - hw/xen/xen-mapcache.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c -index f81b75d216..6544e331e0 100644 ---- a/hw/xen/xen-mapcache.c -+++ b/hw/xen/xen-mapcache.c -@@ -620,7 +620,7 @@ static void *xen_map_grant_dyn(MemoryRegion **mr, hwaddr addr, hwaddr *plen, - unsigned int i; - unsigned int nrefs = (page_off + *plen + XC_PAGE_SIZE - 1) >> XC_PAGE_SHIFT; - uint32_t ref = (addr - XEN_GRANT_ADDR_OFF) >> XC_PAGE_SHIFT; -- uint32_t *refs; -+ uint32_t *refs = NULL; - unsigned int prot = PROT_READ; - struct XENMappedGrantRegion *mgr = NULL; - --- -2.25.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0007-xen-skip-ioreq-creation-on-ioreq-registration-failur.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0007-xen-skip-ioreq-creation-on-ioreq-registration-failur.patch deleted file mode 100644 index 83a18c08..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0007-xen-skip-ioreq-creation-on-ioreq-registration-failur.patch +++ /dev/null @@ -1,42 +0,0 @@ -From fa475ec44fc78ff246e6536c8b9d408abadbb4a4 Mon Sep 17 00:00:00 2001 -From: Stefano Stabellini -Date: Fri, 1 Jul 2022 18:50:59 -0700 -Subject: [PATCH 07/16] xen: skip ioreq creation on ioreq registration failure - -On ARM it is possible to have a functioning xenpv machine with only the -PV backends and no IOREQ server. If the IOREQ server creation fails -continue to the PV backends initialization. - -Signed-off-by: Stefano Stabellini ---- - hw/xen/xen-hvm-common.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c -index 67f76f6010..7e7d23397f 100644 ---- a/hw/xen/xen-hvm-common.c -+++ b/hw/xen/xen-hvm-common.c -@@ -780,7 +780,11 @@ void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, - goto err; - } - -- xen_create_ioreq_server(xen_domid, &state->ioservid); -+ rc = xen_create_ioreq_server(xen_domid, &state->ioservid); -+ if (rc) { -+ DPRINTF("xen: failed to create ioreq server\n"); -+ goto no_ioreq; -+ } - - state->exit.notify = xen_exit_notifier; - qemu_add_exit_notifier(&state->exit); -@@ -845,6 +849,7 @@ void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, - QLIST_INIT(&state->dev_list); - device_listener_register(&state->device_listener); - -+no_ioreq: - xen_bus_init(); - - /* Initialize backend core & drivers */ --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0008-accel-xen-xen-all-export-xenstore_record_dm_state.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0008-accel-xen-xen-all-export-xenstore_record_dm_state.patch deleted file mode 100644 index 881076fb..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0008-accel-xen-xen-all-export-xenstore_record_dm_state.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 13443fe86bb100849c55b41873f48e0b121c7bc0 Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Fri, 1 Jul 2022 17:28:14 -0700 -Subject: [PATCH 08/16] accel/xen/xen-all: export xenstore_record_dm_state - -Signed-off-by: Vikram Garhwal -Signed-off-by: Stefano Stabellini -Reviewed-by: Stefano Stabellini ---- - accel/xen/xen-all.c | 2 +- - include/hw/xen/xen.h | 2 ++ - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c -index 69aa7d018b..276625b78b 100644 ---- a/accel/xen/xen-all.c -+++ b/accel/xen/xen-all.c -@@ -100,7 +100,7 @@ void xenstore_store_pv_console_info(int i, Chardev *chr) - } - - --static void xenstore_record_dm_state(struct xs_handle *xs, const char *state) -+void xenstore_record_dm_state(struct xs_handle *xs, const char *state) - { - char path[50]; - -diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h -index afdf9c436a..31e9538a5c 100644 ---- a/include/hw/xen/xen.h -+++ b/include/hw/xen/xen.h -@@ -9,6 +9,7 @@ - */ - - #include "exec/cpu-common.h" -+#include - - /* xen-machine.c */ - enum xen_mode { -@@ -31,5 +32,6 @@ qemu_irq *xen_interrupt_controller_init(void); - void xenstore_store_pv_console_info(int i, Chardev *chr); - - void xen_register_framebuffer(struct MemoryRegion *mr); -+void xenstore_record_dm_state(struct xs_handle *xs, const char *state); - - #endif /* QEMU_HW_XEN_H */ --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0008-hw-arm-Add-grant-mapping.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0008-hw-arm-Add-grant-mapping.patch deleted file mode 100644 index 3b83d229..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0008-hw-arm-Add-grant-mapping.patch +++ /dev/null @@ -1,39 +0,0 @@ -From b5e5f60de37bb6f71bc34ecb989c31ef5c834272 Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Tue, 31 Jan 2023 21:46:43 +0000 -Subject: [PATCH 8/8] hw: arm: Add grant mapping. - -Add support for grant mapping and change qemu machine name to xenpvh. - -Signed-off-by: Vikram Garhwal -Acked-by: Stefano Stabellini ---- - hw/arm/xen_arm.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c -index 4ac425a3c5..392bed7367 100644 ---- a/hw/arm/xen_arm.c -+++ b/hw/arm/xen_arm.c -@@ -35,7 +35,7 @@ - #include "sysemu/tpm.h" - #include "hw/xen/arch_hvm.h" - --#define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpv") -+#define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") - OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) - - static MemoryListener xen_memory_listener = { -@@ -115,6 +115,9 @@ static void xen_init_ram(MachineState *machine) - DPRINTF("Initialized region xen.ram.hi: base 0x%llx size 0x%lx\n", - GUEST_RAM1_BASE, ram_size[1]); - } -+ -+ DPRINTF("init grant ram mapping for XEN\n"); -+ ram_grants = *xen_init_grant_ram(); - } - - void arch_handle_ioreq(XenIOState *state, ioreq_t *req) --- -2.25.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0009-xen-hvm-enable-xen-hvm-common-build-for-ARM.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0009-xen-hvm-enable-xen-hvm-common-build-for-ARM.patch deleted file mode 100644 index 1b1aea76..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0009-xen-hvm-enable-xen-hvm-common-build-for-ARM.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 2e6a9f464fd1f247c41ce3666ff3e3f66920d0b7 Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Fri, 1 Jul 2022 17:28:15 -0700 -Subject: [PATCH 09/16] xen-hvm: enable xen-hvm-common build for ARM - -Add CONFIG_XEN for aarch64 device and change xen-hvm-common.c to -support build for ARM targets. - -Signed-off-by: Vikram Garhwal -Acked-by: Stefano Stabellini -Signed-off-by: Stefano Stabellini ---- - hw/arm/meson.build | 1 + - meson.build | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -diff --git a/hw/arm/meson.build b/hw/arm/meson.build -index 92f9f6e000..3aac913bfd 100644 ---- a/hw/arm/meson.build -+++ b/hw/arm/meson.build -@@ -62,5 +62,6 @@ arm_ss.add(when: 'CONFIG_FSL_IMX7', if_true: files('fsl-imx7.c', 'mcimx7d-sabre. - arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c', 'smmuv3.c')) - arm_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c')) - arm_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) -+arm_ss.add_all(xen_ss) - - hw_arch += {'arm': arm_ss} -diff --git a/meson.build b/meson.build -index 5c6b5a1c75..b94f0cd76e 100644 ---- a/meson.build -+++ b/meson.build -@@ -125,7 +125,7 @@ endif - if cpu in ['x86', 'x86_64', 'arm', 'aarch64'] - # i386 emulator provides xenpv machine type for multiple architectures - accelerator_targets += { -- 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'], -+ 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu'], - } - endif - if cpu in ['x86', 'x86_64'] --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch deleted file mode 100644 index fc979b52..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch +++ /dev/null @@ -1,230 +0,0 @@ -From 5618a18b1f12d567a8ef85240d55b841e18ef472 Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Fri, 1 Jul 2022 17:28:16 -0700 -Subject: [PATCH 10/16] hw/arm: introduce xenpv machine - -Create a new machine xenpv which creates a IOREQ server to connect -with Xen. It also creates a tpm-tis-device which connects to swtpm to -support TPM functionalities. - -Xen IOREQ connection expect the TARGET_PAGE_SIZE to 4096, and the xenpv -machine on ARM will have no CPU definitions. We need to define -TARGET_PAGE_SIZE appropriately ourselves. - -Signed-off-by: Vikram Garhwal -Signed-off-by: Stefano Stabellini -Reviewed-by: Stefano Stabellini ---- - hw/arm/meson.build | 1 + - hw/arm/xen_arm.c | 156 ++++++++++++++++++++++++++++++++++ - include/hw/arm/xen_arch_hvm.h | 12 +++ - include/hw/xen/arch_hvm.h | 2 + - 4 files changed, 171 insertions(+) - create mode 100644 hw/arm/xen_arm.c - create mode 100644 include/hw/arm/xen_arch_hvm.h - -diff --git a/hw/arm/meson.build b/hw/arm/meson.build -index 3aac913bfd..0cae024374 100644 ---- a/hw/arm/meson.build -+++ b/hw/arm/meson.build -@@ -62,6 +62,7 @@ arm_ss.add(when: 'CONFIG_FSL_IMX7', if_true: files('fsl-imx7.c', 'mcimx7d-sabre. - arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c', 'smmuv3.c')) - arm_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c')) - arm_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) -+arm_ss.add(when: 'CONFIG_XEN', if_true: files('xen_arm.c')) - arm_ss.add_all(xen_ss) - - hw_arch += {'arm': arm_ss} -diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c -new file mode 100644 -index 0000000000..0922e3db84 ---- /dev/null -+++ b/hw/arm/xen_arm.c -@@ -0,0 +1,156 @@ -+/* -+ * QEMU ARM Xen PV Machine -+ * -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to deal -+ * in the Software without restriction, including without limitation the rights -+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -+ * copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -+ * THE SOFTWARE. -+ */ -+ -+#include "qemu/osdep.h" -+#include "qemu/error-report.h" -+#include "qapi/qapi-commands-migration.h" -+#include "hw/boards.h" -+#include "hw/sysbus.h" -+#include "sysemu/block-backend.h" -+#include "sysemu/tpm_backend.h" -+#include "sysemu/sysemu.h" -+#include "hw/xen/xen-legacy-backend.h" -+#include "hw/xen/xen-hvm-common.h" -+#include "sysemu/tpm.h" -+#include "hw/xen/arch_hvm.h" -+ -+#define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpv") -+OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) -+ -+static MemoryListener xen_memory_listener = { -+ .region_add = xen_region_add, -+ .region_del = xen_region_del, -+ .log_start = NULL, -+ .log_stop = NULL, -+ .log_sync = NULL, -+ .log_global_start = NULL, -+ .log_global_stop = NULL, -+ .priority = 10, -+}; -+ -+struct XenArmState { -+ /*< private >*/ -+ MachineState parent; -+ -+ XenIOState *state; -+}; -+ -+void arch_handle_ioreq(XenIOState *state, ioreq_t *req) -+{ -+ hw_error("Invalid ioreq type 0x%x\n", req->type); -+ -+ return; -+} -+ -+void arch_xen_set_memory(XenIOState *state,MemoryRegionSection *section, -+ bool add) -+{ -+} -+ -+void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) -+{ -+} -+ -+void qmp_xen_set_global_dirty_log(bool enable, Error **errp) -+{ -+} -+ -+static int xen_init_ioreq(XenIOState *state, unsigned int max_cpus) -+{ -+ xen_dmod = xendevicemodel_open(0, 0); -+ xen_xc = xc_interface_open(0, 0, 0); -+ -+ if (xen_xc == NULL) { -+ perror("xen: can't open xen interface\n"); -+ return -1; -+ } -+ -+ xen_fmem = xenforeignmemory_open(0, 0); -+ if (xen_fmem == NULL) { -+ perror("xen: can't open xen fmem interface\n"); -+ xc_interface_close(xen_xc); -+ return -1; -+ } -+ -+ xen_register_ioreq(state, max_cpus, xen_memory_listener); -+ -+ xenstore_record_dm_state(xenstore, "running"); -+ -+ return 0; -+} -+ -+ -+static void xen_arm_init(MachineState *machine) -+{ -+ DeviceState *dev; -+ SysBusDevice *busdev; -+ Error *errp = NULL; -+ XenArmState *xam = XEN_ARM(machine); -+ -+ xam->state = g_new0(XenIOState, 1); -+ -+ if (xen_init_ioreq(xam->state, machine->smp.cpus)) { -+ return; -+ } -+ -+ TPMBackend *be = qemu_find_tpm_be("tpm0"); -+ if (be == NULL) { -+ DPRINTF("Couldn't fine the backend for tpm0\n"); -+ return; -+ } -+ -+ dev = qdev_new(TYPE_TPM_TIS_SYSBUS); -+ object_property_set_link(OBJECT(dev), "tpmdev", OBJECT(be), &errp); -+ object_property_set_str(OBJECT(dev), "tpmdev", be->id, &errp); -+ busdev = SYS_BUS_DEVICE(dev); -+ sysbus_realize_and_unref(busdev, &error_fatal); -+ sysbus_mmio_map(busdev, 0, GUEST_TPM_BASE); -+ -+ DPRINTF("Connected tpmdev at address 0x%lx\n", GUEST_TPM_BASE); -+ -+ return; -+} -+ -+static void xen_arm_machine_class_init(ObjectClass *oc, void *data) -+{ -+ -+ MachineClass *mc = MACHINE_CLASS(oc); -+ mc->desc = "Xen Para-virtualized PC"; -+ mc->init = xen_arm_init; -+ mc->max_cpus = 1; -+ machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); -+} -+ -+static const TypeInfo xen_arm_machine_type = { -+ .name = TYPE_XEN_ARM, -+ .parent = TYPE_MACHINE, -+ .class_init = xen_arm_machine_class_init, -+ .instance_size = sizeof(XenArmState), -+}; -+ -+static void xen_arm_machine_register_types(void) -+{ -+ type_register_static(&xen_arm_machine_type); -+} -+ -+type_init(xen_arm_machine_register_types) -diff --git a/include/hw/arm/xen_arch_hvm.h b/include/hw/arm/xen_arch_hvm.h -new file mode 100644 -index 0000000000..f645dfec28 ---- /dev/null -+++ b/include/hw/arm/xen_arch_hvm.h -@@ -0,0 +1,12 @@ -+#ifndef HW_XEN_ARCH_ARM_HVM_H -+#define HW_XEN_ARCH_ARM_HVM_H -+ -+#include -+void arch_handle_ioreq(XenIOState *state, ioreq_t *req); -+void arch_xen_set_memory(XenIOState *state, -+ MemoryRegionSection *section, -+ bool add); -+ -+#undef TARGET_PAGE_SIZE -+#define TARGET_PAGE_SIZE 4096 -+#endif -diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h -index 26674648d8..c7c515220d 100644 ---- a/include/hw/xen/arch_hvm.h -+++ b/include/hw/xen/arch_hvm.h -@@ -1,3 +1,5 @@ - #if defined(TARGET_I386) || defined(TARGET_X86_64) - #include "hw/i386/xen_arch_hvm.h" -+#elif defined(TARGET_ARM) || defined(TARGET_ARM_64) -+#include "hw/arm/xen_arch_hvm.h" - #endif --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0011-meson.build-do-not-set-have_xen_pci_passthrough-for-.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0011-meson.build-do-not-set-have_xen_pci_passthrough-for-.patch deleted file mode 100644 index dad3029f..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0011-meson.build-do-not-set-have_xen_pci_passthrough-for-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From f4ff3490639dea08fb70ec69d60fe73ef479073b Mon Sep 17 00:00:00 2001 -From: Stefano Stabellini -Date: Thu, 7 Jul 2022 14:03:41 -0700 -Subject: [PATCH 11/16] meson.build: do not set have_xen_pci_passthrough for - aarch64 targets -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -have_xen_pci_passthrough is only used for Xen x86 VMs. - -Signed-off-by: Stefano Stabellini -Reviewed-by: Alex Bennée ---- - meson.build | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/meson.build b/meson.build -index b94f0cd76e..a4965251ab 100644 ---- a/meson.build -+++ b/meson.build -@@ -1469,6 +1469,8 @@ have_xen_pci_passthrough = get_option('xen_pci_passthrough') \ - error_message: 'Xen PCI passthrough requested but Xen not enabled') \ - .require(targetos == 'linux', - error_message: 'Xen PCI passthrough not available on this platform') \ -+ .require(cpu == 'x86' or cpu == 'x86_64', -+ error_message: 'Xen PCI passthrough not available on this platform') \ - .allowed() - - --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0012-xen-arm-call-qemu_find_tpm_be-if-CONFIG_TPM.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0012-xen-arm-call-qemu_find_tpm_be-if-CONFIG_TPM.patch deleted file mode 100644 index f80a0873..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0012-xen-arm-call-qemu_find_tpm_be-if-CONFIG_TPM.patch +++ /dev/null @@ -1,72 +0,0 @@ -From a26982a55fa5f47116b344ca5d411f00c3a2b422 Mon Sep 17 00:00:00 2001 -From: Stefano Stabellini -Date: Thu, 7 Jul 2022 14:35:33 -0700 -Subject: [PATCH 12/16] xen-arm: call qemu_find_tpm_be if CONFIG_TPM - -qemu_find_tpm_be is only availablen when CONFIG_TPM is enabled. -So #ifdef the call to make sure the code builds correctly even when -CONFIG_TPM is not enabled. - -Signed-off-by: Stefano Stabellini ---- - hw/arm/xen_arm.c | 28 +++++++++++++++++----------- - 1 file changed, 17 insertions(+), 11 deletions(-) - -diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c -index 0922e3db84..f248b5744a 100644 ---- a/hw/arm/xen_arm.c -+++ b/hw/arm/xen_arm.c -@@ -99,26 +99,18 @@ static int xen_init_ioreq(XenIOState *state, unsigned int max_cpus) - return 0; - } - -- --static void xen_arm_init(MachineState *machine) -+static void xen_enable_tpm(void) - { -+#ifdef CONFIG_TPM -+ Error *errp = NULL; - DeviceState *dev; - SysBusDevice *busdev; -- Error *errp = NULL; -- XenArmState *xam = XEN_ARM(machine); -- -- xam->state = g_new0(XenIOState, 1); -- -- if (xen_init_ioreq(xam->state, machine->smp.cpus)) { -- return; -- } - - TPMBackend *be = qemu_find_tpm_be("tpm0"); - if (be == NULL) { - DPRINTF("Couldn't fine the backend for tpm0\n"); - return; - } -- - dev = qdev_new(TYPE_TPM_TIS_SYSBUS); - object_property_set_link(OBJECT(dev), "tpmdev", OBJECT(be), &errp); - object_property_set_str(OBJECT(dev), "tpmdev", be->id, &errp); -@@ -127,6 +119,20 @@ static void xen_arm_init(MachineState *machine) - sysbus_mmio_map(busdev, 0, GUEST_TPM_BASE); - - DPRINTF("Connected tpmdev at address 0x%lx\n", GUEST_TPM_BASE); -+#endif -+} -+ -+static void xen_arm_init(MachineState *machine) -+{ -+ XenArmState *xam = XEN_ARM(machine); -+ -+ xam->state = g_new0(XenIOState, 1); -+ -+ if (xen_init_ioreq(xam->state, machine->smp.cpus)) { -+ return; -+ } -+ -+ xen_enable_tpm(); - - return; - } --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0013-arm-xenpv-fix-TPM-address-print-warning.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0013-arm-xenpv-fix-TPM-address-print-warning.patch deleted file mode 100644 index 1aa09efb..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0013-arm-xenpv-fix-TPM-address-print-warning.patch +++ /dev/null @@ -1,27 +0,0 @@ -From c5b128668d9cd1e1cb4da80d5bc8aaebc6ff2e19 Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Fri, 23 Dec 2022 00:06:29 +0000 -Subject: [PATCH 13/16] arm: xenpv: fix TPM address print warning - -Signed-off-by: Vikram Garhwal -Acked-by: Stefano Stabellini ---- - hw/arm/xen_arm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c -index f248b5744a..153cedfeb4 100644 ---- a/hw/arm/xen_arm.c -+++ b/hw/arm/xen_arm.c -@@ -118,7 +118,7 @@ static void xen_enable_tpm(void) - sysbus_realize_and_unref(busdev, &error_fatal); - sysbus_mmio_map(busdev, 0, GUEST_TPM_BASE); - -- DPRINTF("Connected tpmdev at address 0x%lx\n", GUEST_TPM_BASE); -+ DPRINTF("Connected tpmdev at address 0x%llx\n", GUEST_TPM_BASE); - #endif - } - --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0014-xen_arm-Create-virtio-mmio-devices-during-initializa.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0014-xen_arm-Create-virtio-mmio-devices-during-initializa.patch deleted file mode 100644 index a6925acf..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0014-xen_arm-Create-virtio-mmio-devices-during-initializa.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 3dc39d71c3652bea37dc955d5dbf8cd391d2aed0 Mon Sep 17 00:00:00 2001 -From: Oleksandr Tyshchenko -Date: Sat, 30 Jul 2022 17:51:19 +0300 -Subject: [PATCH 14/16] xen_arm: Create virtio-mmio devices during - initialization - -In order to use virtio backends we need to allocate virtio-mmio -parameters (irq and base) and register corresponding buses. - -Use the constants defined in public header arch-arm.h to be -aligned with the toolstack. So the number of current supported -virtio-mmio devices is 10. - -For the interrupts triggering use already existing on Arm -device-model hypercall. - -The toolstack should then insert the same amount of device nodes -into guest device-tree. - -Signed-off-by: Oleksandr Tyshchenko -Signed-off-by: Vikram Garhwal -Reviewed-by: Stefano Stabellini ---- - hw/arm/xen_arm.c | 29 +++++++++++++++++++++++++++++ - 1 file changed, 29 insertions(+) - -diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c -index 153cedfeb4..2012ee7aff 100644 ---- a/hw/arm/xen_arm.c -+++ b/hw/arm/xen_arm.c -@@ -25,6 +25,7 @@ - #include "qemu/error-report.h" - #include "qapi/qapi-commands-migration.h" - #include "hw/boards.h" -+#include "hw/irq.h" - #include "hw/sysbus.h" - #include "sysemu/block-backend.h" - #include "sysemu/tpm_backend.h" -@@ -55,6 +56,32 @@ struct XenArmState { - XenIOState *state; - }; - -+#define VIRTIO_MMIO_DEV_SIZE 0x200 -+ -+#define NR_VIRTIO_MMIO_DEVICES \ -+ (GUEST_VIRTIO_MMIO_SPI_LAST - GUEST_VIRTIO_MMIO_SPI_FIRST) -+ -+static void xen_set_irq(void *opaque, int irq, int level) -+{ -+ xendevicemodel_set_irq_level(xen_dmod, xen_domid, irq, level); -+} -+ -+static void xen_create_virtio_mmio_devices(XenArmState *xam) -+{ -+ int i; -+ -+ for (i = 0; i < NR_VIRTIO_MMIO_DEVICES; i++) { -+ hwaddr base = GUEST_VIRTIO_MMIO_BASE + i * VIRTIO_MMIO_DEV_SIZE; -+ qemu_irq irq = qemu_allocate_irq(xen_set_irq, NULL, -+ GUEST_VIRTIO_MMIO_SPI_FIRST + i); -+ -+ 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); -+ } -+} -+ - void arch_handle_ioreq(XenIOState *state, ioreq_t *req) - { - hw_error("Invalid ioreq type 0x%x\n", req->type); -@@ -132,6 +159,8 @@ static void xen_arm_init(MachineState *machine) - return; - } - -+ xen_create_virtio_mmio_devices(xam); -+ - xen_enable_tpm(); - - return; --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch deleted file mode 100644 index 7c2b272d..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch +++ /dev/null @@ -1,105 +0,0 @@ -From a284a53c5374e19ac37b884f2dd50293e7c8070e Mon Sep 17 00:00:00 2001 -From: Oleksandr Tyshchenko -Date: Sat, 30 Jul 2022 17:18:06 +0300 -Subject: [PATCH 15/16] xen_arm: Initialize RAM and add hi/low memory regions - -In order to use virtio backends we need to initialize RAM for the -xen-mapcache (which is responsible for mapping guest memory using foreign -mapping) to work. Calculate and add hi/low memory regions based on -machine->ram_size. - -Use the constants defined in public header arch-arm.h to be aligned with the -toolstack. - -The toolstack should then pass real ram_size using "-m" arg. -If "-m" is not given, create a QEMU machine without IOREQ, TPM and VIRTIO to -keep it usable for /etc/init.d/xencommons. - -Signed-off-by: Oleksandr Tyshchenko -Signed-off-by: Vikram Garhwal -Reviewed-by: Stefano Stabellini ---- - hw/arm/xen_arm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 46 insertions(+) - -diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c -index 2012ee7aff..fde919df29 100644 ---- a/hw/arm/xen_arm.c -+++ b/hw/arm/xen_arm.c -@@ -56,6 +56,8 @@ struct XenArmState { - XenIOState *state; - }; - -+static MemoryRegion ram_lo, ram_hi; -+ - #define VIRTIO_MMIO_DEV_SIZE 0x200 - - #define NR_VIRTIO_MMIO_DEVICES \ -@@ -82,6 +84,39 @@ static void xen_create_virtio_mmio_devices(XenArmState *xam) - } - } - -+static void xen_init_ram(MachineState *machine) -+{ -+ MemoryRegion *sysmem = get_system_memory(); -+ ram_addr_t block_len, ram_size[GUEST_RAM_BANKS]; -+ -+ if (machine->ram_size <= GUEST_RAM0_SIZE) { -+ ram_size[0] = machine->ram_size; -+ ram_size[1] = 0; -+ block_len = GUEST_RAM0_BASE + ram_size[0]; -+ } else { -+ ram_size[0] = GUEST_RAM0_SIZE; -+ ram_size[1] = machine->ram_size - GUEST_RAM0_SIZE; -+ block_len = GUEST_RAM1_BASE + ram_size[1]; -+ } -+ -+ memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len, -+ &error_fatal); -+ -+ 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]); -+ } -+} -+ - void arch_handle_ioreq(XenIOState *state, ioreq_t *req) - { - hw_error("Invalid ioreq type 0x%x\n", req->type); -@@ -155,6 +190,14 @@ 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 will be started without" -+ " TPM, IOREQ and Virtio-MMIO backends\n"); -+ return; -+ } -+ -+ xen_init_ram(machine); -+ - if (xen_init_ioreq(xam->state, machine->smp.cpus)) { - return; - } -@@ -173,6 +216,9 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data) - mc->desc = "Xen Para-virtualized PC"; - mc->init = xen_arm_init; - mc->max_cpus = 1; -+ /* Set explicitly here to make sure that real ram_size is passed */ -+ mc->default_ram_size = 0; -+ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); - } - --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0016-xen_arm-Add-accel-xen-and-drop-extra-interface-openi.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0016-xen_arm-Add-accel-xen-and-drop-extra-interface-openi.patch deleted file mode 100644 index 14f2e240..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0016-xen_arm-Add-accel-xen-and-drop-extra-interface-openi.patch +++ /dev/null @@ -1,79 +0,0 @@ -From a730d5ea4a0445a8c694b56583dd06bd000fae74 Mon Sep 17 00:00:00 2001 -From: Vikram Garhwal -Date: Wed, 4 Jan 2023 23:05:25 +0000 -Subject: [PATCH 16/16] xen_arm: Add "accel = xen" and drop extra interface - openings - -In order to use virtio backends we need to make sure that Xen accelerator -is enabled (xen_enabled() returns true) as the memory/cache systems -check for xen_enabled() to perform specific actions. Without that -the xen-mapcache (which is needed for mapping guest memory) is not in use. - -Also drop extra interface opening as this is already done in xen-all.c -(so drop xen_init_ioreq() completely) and skip virtio/tpm initialization -if device emulation is not available. - -Signed-off-by: Oleksandr Tyshchenko -Signed-off-by: Vikram Garhwal -Reviewed-by: Stefano Stabellini ---- - hw/arm/xen_arm.c | 29 ++--------------------------- - 1 file changed, 2 insertions(+), 27 deletions(-) - -diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c -index fde919df29..4ac425a3c5 100644 ---- a/hw/arm/xen_arm.c -+++ b/hw/arm/xen_arm.c -@@ -137,30 +137,6 @@ void qmp_xen_set_global_dirty_log(bool enable, Error **errp) - { - } - --static int xen_init_ioreq(XenIOState *state, unsigned int max_cpus) --{ -- xen_dmod = xendevicemodel_open(0, 0); -- xen_xc = xc_interface_open(0, 0, 0); -- -- if (xen_xc == NULL) { -- perror("xen: can't open xen interface\n"); -- return -1; -- } -- -- xen_fmem = xenforeignmemory_open(0, 0); -- if (xen_fmem == NULL) { -- perror("xen: can't open xen fmem interface\n"); -- xc_interface_close(xen_xc); -- return -1; -- } -- -- xen_register_ioreq(state, max_cpus, xen_memory_listener); -- -- xenstore_record_dm_state(xenstore, "running"); -- -- return 0; --} -- - static void xen_enable_tpm(void) - { - #ifdef CONFIG_TPM -@@ -198,9 +174,7 @@ static void xen_arm_init(MachineState *machine) - - xen_init_ram(machine); - -- if (xen_init_ioreq(xam->state, machine->smp.cpus)) { -- return; -- } -+ xen_register_ioreq(xam->state, machine->smp.cpus, xen_memory_listener); - - xen_create_virtio_mmio_devices(xam); - -@@ -218,6 +192,7 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data) - mc->max_cpus = 1; - /* Set explicitly here to make sure that real ram_size is passed */ - mc->default_ram_size = 0; -+ mc->default_machine_opts = "accel=xen"; - - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); - } --- -2.17.1 - diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx_2023%.bbappend b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx_2023%.bbappend deleted file mode 100644 index 5cb9f0d0..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx_2023%.bbappend +++ /dev/null @@ -1,5 +0,0 @@ -require qemu-tpm.inc -require qemu-xen_7.1.inc - -# We do not want QEMU, on the target to be configured with OpenGL -PACKAGECONFIG:remove:class-target = "virglrenderer epoxy gtk+" diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu_7.1%.bbappend b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu_7.1%.bbappend deleted file mode 100644 index 5cb9f0d0..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu_7.1%.bbappend +++ /dev/null @@ -1,5 +0,0 @@ -require qemu-tpm.inc -require qemu-xen_7.1.inc - -# We do not want QEMU, on the target to be configured with OpenGL -PACKAGECONFIG:remove:class-target = "virglrenderer epoxy gtk+" -- cgit v1.2.3-54-g00ecf