From 7bf4e92c200c494cc7df789731cedd43c6a18971 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 17 Dec 2015 12:04:45 +0000 Subject: [PATCH] WIP xendevicemodel.h This is just the header docs as a starting point for discussion for some further interfaces. Implementation notes: xendevicemodel_create_vram_region: - xen-hvm.c:xen_add_to_physmap, only used for vram (explicit check). - XENMEM_add_to_physmap + XEN_DOMCTL_pin_mem_cacheattr - Is first XENMEM_populate_physmap'd in xen-hvm.c:xen_ram_alloc. Some refactoring required. - XEN_DOMCTL_pin_mem_cacheattr needs to become a stable API - Using XEN_DOMCTL_MEM_CACHEATTR_WB. - xc_domain_pin_memory_cacheattr can likely be removed from libxc xendevicemodel_destroy_vram_region: - xen-hvm.c:xen_remove_from_physmap, implicit check via presence of physmap, which is only for vram (see xen_add_to_physmap) - XENMEM_add_to_physmap - Don't need to undo pin_mem_cacheattr? --- docs/misc/toolstack-library-abis.pandoc | 74 ++++++++++++------- .../libs/devicemodel/include/xendevicemodel.h | 55 ++++++++++++++ 2 files changed, 103 insertions(+), 26 deletions(-) diff --git a/docs/misc/toolstack-library-abis.pandoc b/docs/misc/toolstack-library-abis.pandoc index 9b52fbe349..8ef0a9180f 100644 --- a/docs/misc/toolstack-library-abis.pandoc +++ b/docs/misc/toolstack-library-abis.pandoc @@ -176,6 +176,28 @@ Interface Underlying interface Known external `xenforeignmemory_close` `close(2)` `xenforeignmemory_map` `IOCTL_PRIVCMD_MMAPBATCH` etc +## `libxendevicemodel`: functionality for x86/HVM device models + +Interface Underlying interface +------------------------------------------------- ------------------------------ +`xendevicemodel_shutdown` `SCHEDOP_remote_shutdown` +`xendevicemodel_reboot` `SCHEDOP_remote_shutdown` +`xendevicemodel_set_pci_intx_level` `HVMOP_set_pci_intx_level` +`xendevicemodel_route_pci_intx_to_isa_irq` `HVMOP_set_pci_link_route` +`xendevicemodel_set_isa_irq_level` `HVMOP_set_isa_irq_level` +`xendevicemodel_inject_msi` `HVMOP_inject_msi` +`xendevicemodel_create_ioreq_server` `HVMOP_create_ioreq_server` +`xendevicemodel_get_ioreq_server_info` `HVMOP_get_ioreq_server_info` +`xendevicemodel_map_io_range_to_ioreq_server` `HVMOP_map_io_range_to_ioreq_server` +`xendevicemodel_unmap_io_range_from_ioreq_server` `HVMOP_unmap_io_range_from_ioreq_server` +`xendevicemodel_map_pcidev_to_ioreq_server` `HVMOP_map_io_range_to_ioreq_server` +`xendevicemodel_unmap_pcidev_from_ioreq_server` `HVMOP_unmap_io_range_from_ioreq_server` +`xendevicemodel_destroy_ioreq_server` `HVMOP_destroy_ioreq_server` +`xendevicemodel_set_ioreq_server_state` `HVMOP_set_ioreq_server_state` +`xendevicemodel_mark_memory_region_dirty` `HVMOP_modified_memory` +`xendevicemodel_make_ram_region_rw` `HVMOP_set_mem_type` +`xendevicemodel_make_ram_region_ro` `HVMOP_set_mem_type` + # Unstable libraries These libraries do not provide a stable interface and are required to @@ -427,7 +449,7 @@ Symbols: - xc_domain_set_tsc_info - xc_domain_set_virq_handler - xc_domain_setvnuma - - xc_domain_shutdown (`SCHEDOP_remote_shutd`). Used by qemu-dm. + - xc_domain_shutdown (`SCHEDOP_remote_shutd`). - xc_domain_subscribe_for_suspend - xc_domain_suppress_spurious_page_faults - xc_domain_unbind_msi_irq @@ -472,7 +494,6 @@ Symbols: - xc_getcpuinfo - xc_get_cpumap_size - xc_get_device_group - - xc_get_hvm_param (Legacy, replaced by `xc_hvm_param_get`) - xc_get_last_error - xc_get_machine_memory_map. Used by kexec-tools - xc_get_max_cpus. Used by kexec-tools @@ -484,24 +505,16 @@ Symbols: - xc_get_pfn_type_batch - xc_get_tot_pages - xc_get_vcpu_migration_delay - - xc_hvm_create_ioreq_server - - xc_hvm_destroy_ioreq_server - - xc_hvm_get_ioreq_server_info - xc_hvm_inject_msi (`HVMOP_inject_msi`). Used by qemu-dm. - xc_hvm_inject_trap - - xc_hvm_map_io_range_to_ioreq_server - - xc_hvm_map_pcidev_to_ioreq_server - xc_hvm_modified_memory (`HVMOP_modified_memory`). Used by qemu-dm. - xc_hvm_param_get (`HVMOP_get_param`) - xc_hvm_param_set (`HVMOP_set_param`) - - xc_hvm_set_ioreq_server_state - xc_hvm_set_isa_irq_level (`HVMOP_set_isa_irq_level`). Used by qemu-dm. - xc_hvm_set_mem_type (`HVMOP_set_mem_type`). Used by qemu-dm. - xc_hvm_set_pci_intx_level (`HVMOP_set_pci_intx_level`). Used by qemu-dm. - xc_hvm_set_pci_link_route (`HVMOP_set_pci_link_route`). Used by qemu-dm. - xc_hvm_track_dirty_vram (`HVMOP_track_dirty_vram`). Used by qemu-dm. - - xc_hvm_unmap_io_range_from_ioreq_server - - xc_hvm_unmap_pcidev_from_ioreq_server - xc_lockprof_query - xc_lockprof_query_number - xc_lockprof_reset @@ -591,7 +604,6 @@ Symbols: - xc_set_cpufreq_gov - xc_set_cpufreq_para - xc_set_cpuidle_max_cstate - - xc_set_hvm_param (`HVMOP_set_param`, legacy, replaced by `xc_hvm_param_set`). Used by qemu-dm. - xc_set_mem_access - xc_set_progress_prefix - xc_set_sched_opt_smt @@ -809,7 +821,6 @@ Use privcmd and evtchn device handles: - xenevtchn_pending - xenevtchn_unbind - xenevtchn_unmask - - xc_get_hvm_param - xc_hvm_inject_msi - xc_hvm_modified_memory - xc_hvm_set_isa_irq_level @@ -826,7 +837,10 @@ Use privcmd and evtchn device handles: - xc_physdev_map_pirq - xc_physdev_map_pirq_msi - xc_physdev_unmap_pirq - - xc_set_hvm_param + - xendevicemodel_shutdown + - xendevicemodel_reboot + - xendevicemodel_s3_suspend + - xendevicemodel_s3_awaken ### By functional area @@ -849,22 +863,30 @@ Interface S Underlying Interface S Other user `xenforeignmemory_map` Y `xenforeignmemory_open` Y `xenforeignmemory_unmap` Y +`xendevicemodel_shutdown` Y +`xendevicemodel_reboot` Y +`xendevicemodel_s3_suspend` Y +`xendevicemodel_s3_awaken` Y +`xendevicemodel_set_pci_intx_l...` Y +`xendevicemodel_route_pci_intx...` Y +`xendevicemodel_set_isa_irq_level Y +`xendevicemodel_inject_msi` N `HVMOP_inject_msi` N +`xendevicemodel_create_ioreq_s...` N +`xendevicemodel_get_ioreq_serv...` N +`xendevicemodel_map_io_range_t...` N +`xendevicemodel_unmap_io_range...` N +`xendevicemodel_map_pcidev_to_...` N +`xendevicemodel_unmap_pcidev_f...` N +`xendevicemodel_destroy_ioreq_...` N +`xendevicemodel_set_ioreq_serv...` N +`xendevicemodel_mark_memory_re...` N +`xendevicemodel_make_ram_reg...ro` N `HVMOP_set_mem_type` N +`xendevicemodel_make_ram_reg...rw` N `HVMOP_set_mem_type` N `xc_domain_add_to_physmap` N `XENMEM_add_to_physmap` Y libxc (dombuilder) `xc_domain_populate_physmap_exact` N `XENMEM_populate_physmap` Y libxc (several) `xc_domain_pin_memory_cacheattr` N `XEN_DOMCTL_pin_mem_cacheattr` N None -`xc_domain_shutdown` N `SCHEDOP_remote_shutdown` Y libxl -`xc_set_hvm_param` N `HVM_PARAM_ACPI_S_STATE` Y None -`xc_hvm_inject_msi` N `HVMOP_inject_msi` Y None -`xc_hvm_modified_memory` N `HVMOP_modified_memory` Y None -`xc_hvm_set_isa_irq_level` N `HVMOP_set_isa_irq_level` Y None -`xc_hvm_set_mem_type` N `HVMOP_set_mem_type` Y None -`xc_hvm_set_pci_intx_level` N `HVMOP_set_pci_intx_level` Y None -`xc_hvm_set_pci_link_route` N `HVMOP_set_pci_link_route` Y None -`xc_hvm_track_dirty_vram` N `HVMOP_track_dirty_vram` Y None -`xc_hvm_unmap_io_range_from_ir...` N `HVMOP_IO_RANGE_(PORT|MEM...)` Y None -`xc_hvm_unmap_pcidev_from_iore...` N `HVMOP_unmap_io_range_from...` Y None -`xc_interface_close` -`xc_interface_open` +`xc_hvm_modified_memory` N `HVMOP_modified_memory` N None +`xc_hvm_track_dirty_vram` N `HVMOP_track_dirty_vram` N None #### PCI Passthrough diff --git a/tools/libs/devicemodel/include/xendevicemodel.h b/tools/libs/devicemodel/include/xendevicemodel.h index d410a3aafd..e21c8d9aca 100644 --- a/tools/libs/devicemodel/include/xendevicemodel.h +++ b/tools/libs/devicemodel/include/xendevicemodel.h @@ -325,6 +325,61 @@ int xendevicemodel_destroy_ioreq_server(xendevicemodel_handle *dm, int xendevicemodel_populate_ram(xendevicemodel_handle *dm, xen_pfn_t start_gpfn, size_t nr_pages); +#if 0 +/* + * Populate a region of video RAM starting at vram_start_gpfn by + * taking nr_pages of backing memory from backing_start_pgfn onwards. + * + * The guest physical memory region at backing_start_gpfn must + * currently be populated with regular memory (such as that from + * xendevicemodel_populate_ram) and will become unmapped as a result + * of this call. + * + * The memory region will be given appropriate cache properties for + * video RAM. + * + * On success *r_vram will be set to an opaque cookie. + */ +struct xendevicemodel_vram; +int xendevicemodel_create_vram_region(xendevicemodel_handle *dm, + xen_pfn_t vram_start_gpfn, + xen_pfn_t backing_start_gpfn, + size_t nr_pages, + struct xendevicemodel_vram **r_vram); + +/* + * Undoes (perhaps partially) the effects of a previous + * xendevicemodel_populate_vram. Memory which was previously moved + * from backing_start_gpfn to vram_start_gpfn will be returned to its + * original location. + * + * The address space at vram_start_gpfn will become unmapped and the + * memory at backing_start_gpfn will have cache properties suitable + * for standard RAM. + * + * probably undo the cacheattr, done on populate, which current QEMU + * code does not do. + * + * XXX perhaps have the handle cache a single instance of populate + * vram and have this function undo it with no additional arguments + * (and have populate EBUSY o/w). + */ +int xendevicemodel_destroy_vram(xendevicemodel_handle *dm, + struct xendevicemodel_vram *vram, + xen_pfn_t vram_start_gpfn, + xen_pfn_t backing_start_gpfn, + size_t nr_pages); + +/* XXX only one at a time (globally, not even per vram), must be a + * sub-region of vram */ +/* + * Useful to have a start, stop, sync calls, with a single hyercall buffer? */ +int xendevicemodel_vram_dirtybitmap(xendevicemodel_handle *dm, + struct xendevicemodel_vram *vram, + start, length); + +#endif + #endif /* * Local variables: -- 2.39.5