ANNOUNCE: Removing in-tree ioemu from xen-unstable.hg
With patches just submitted to allow stubdom to work with the new out-of-tree qemu-xen-unstable.git, I think the final obstacle to removing the in-tree ioemu has disappeared. I therefore plan to delete the internal ioemu tree early next week unless anyone has a strong reason to delay this action.
-- Keir
Hello,
Quoted 5 lines · Keir Fraser, le Thu 11 Sep 2008 16:54:51 +0100, a écrit :
With patches just submitted to allow stubdom to work with the new out-of-tree qemu-xen-unstable.git, I think the final obstacle to removing the in-tree ioemu has disappeared. I therefore plan to delete the internal ioemu tree early next week unless anyone has a strong reason to delay this action.
C/S 18383 still needs to be applied to the qemu-xen tree, here is a port.
Samuel
hvm: Use main memory for video memory.
When creating an HVM domain, if e.g. another domain is created before qemu allocates video memory, the extra 8MB memory ballooning is not available any more, because it got consumed by the other domain.
This fixes it by taking video memory from the main memory:
- make hvmloader use e820_malloc to reserve some of the main memory and notify ioemu of its address through the Xen platform PCI card.
- add XENMAPSPACE_mfn to the xen_add_to_physmap memory op, to allow ioemu to move the MFNs between the original position and the PCI mapping, when LFB acceleration is disabled/enabled
- add a remove_from_physmap memory op, to allow ioemu to unmap it completely for the case of old guests with acceleration disabled.
- add xc_domain_memory_translate_gpfn_list to libxc to allow ioemu to get the MFNs of the video memory.
- have xend save the PCI memory space instead of ioemu: if a memory page is there, the guest can access it like usual memory, so xend can safely be responsible to save it. The extra benefit is that live migration will apply the logdirty optimization there too.
- handle old saved images, populating the video memory from ioemu if really needed.
hw/cirrus_vga.c +67 -155
@@ -31,6 +31,7 @@#include "pci.h" #include "console.h" #include "vga_int.h" +#include "qemu-xen.h" #include "exec-all.h"
@@ -2641,65 +2642,28 @@ static CPUWriteMemoryFunc *cirrus_linear_bitblt_write[3] = { }; -/* FIXME Flush the shadow page */ -static int unset_mm_mapping (int xc_handle,uint32_t domid, -unsigned long nr_pages,unsigned int address_bits, -xen_pfn_t *extent_start) +static void set_vram_mapping (CirrusVGAState *s,unsigned long begin,unsigned long end) { -int err =0 ; +unsigned long i; +struct xen_add_to_physmap xatp; +int rc; - err =xc_domain_memory_decrease_reservation (xc_handle, domid, - nr_pages,0 , extent_start); -if (err) -fprintf (stderr,"Failed to decrease physmap\n" ); +if (end > begin +VGA_RAM_SIZE ) + end = begin +VGA_RAM_SIZE ; -return err; -} - -static int set_mm_mapping (int xc_handle,uint32_t domid, -unsigned long nr_pages,unsigned int address_bits, -xen_pfn_t *extent_start) -{ -int err =0 ; - - err =xc_domain_memory_populate_physmap (xc_handle, domid, nr_pages,0 , - address_bits, extent_start); -if (err) { -fprintf (stderr,"Failed to populate physmap\n" ); -return -1 ; - } - -return 0 ; -} - -static void *set_vram_mapping (unsigned long begin,unsigned long end) -{ -xen_pfn_t *extent_start =NULL ; -unsigned long nr_extents; -void *vram_pointer =NULL ; -int i; - -/* align begin and end address */ - begin = begin &TARGET_PAGE_MASK ; - end = begin +VGA_RAM_SIZE ; - end = (end +TARGET_PAGE_SIZE -1 ) &TARGET_PAGE_MASK ; - nr_extents = (end - begin) >>TARGET_PAGE_BITS ; - - extent_start =malloc (sizeof (xen_pfn_t) * nr_extents); -if (extent_start ==NULL ) { -fprintf (stderr,"Failed malloc on set_vram_mapping\n" ); -return NULL ; - } - -memset (extent_start,0 ,sizeof (xen_pfn_t) * nr_extents); +fprintf (logfile,"mapping vram to %lx - %lx\n" , begin, end); -for (i =0 ; i < nr_extents; i++) - extent_start[i] = (begin + i *TARGET_PAGE_SIZE ) >>TARGET_PAGE_BITS ; + xatp.domid = domid; + xatp.space = XENMAPSPACE_mfn; -if (set_mm_mapping (xc_handle, domid, nr_extents,0 , extent_start) <0 ) { -fprintf (logfile,"Failed set_mm_mapping\n" ); -free (extent_start); -return NULL ; +for (i =0 ; i < (end - begin) >>TARGET_PAGE_BITS ; i++) { + xatp.idx = s->vram_mfns[i]; + xatp.gpfn = (begin >>TARGET_PAGE_BITS ) + i; + rc =xc_memory_op (xc_handle, XENMEM_add_to_physmap, &xatp); +if (rc) { +fprintf (stderr,"add_to_physmap MFN %" PRI_xen_pfn" to PFN %" PRI_xen_pfn" failed: %d\n" , xatp.idx, xatp.gpfn, rc); +return ; + } } (void)xc_domain_pin_memory_cacheattr(
@@ -2707,61 +2671,42 @@ static void *set_vram_mapping(unsigned long begin, unsigned long end) begin >>TARGET_PAGE_BITS , end >>TARGET_PAGE_BITS , XEN_DOMCTL_MEM_CACHEATTR_WB); - - vram_pointer =xc_map_foreign_pages (xc_handle, domid, -PROT_READ |PROT_WRITE , - extent_start, nr_extents); -if (vram_pointer ==NULL ) { -fprintf (logfile,"xc_map_foreign_batch vgaram returned error %d\n" , - errno); -free (extent_start); -return NULL ; - } - -memset (vram_pointer,0 , nr_extents *TARGET_PAGE_SIZE ); - -#ifdef CONFIG_STUBDOM -xenfb_pv_display_start (vram_pointer); -#endif - -free (extent_start); - -return vram_pointer; } -static int unset_vram_mapping (unsigned long begin,unsigned long end, -void *mapping) +static void unset_vram_mapping (CirrusVGAState *s,unsigned long begin,unsigned long end) { -xen_pfn_t *extent_start =NULL ; -unsigned long nr_extents; -int i; +if (s->stolen_vram_addr) { +/* We can put it there for xend to save it efficiently */ +set_vram_mapping (s, s->stolen_vram_addr, s->stolen_vram_addr +VGA_RAM_SIZE ); + }else { +/* Old image, we have to unmap them completely */ +struct xen_remove_from_physmap xrfp; +unsigned long i; +int rc; -/* align begin and end address */ +if (end > begin +VGA_RAM_SIZE ) + end = begin +VGA_RAM_SIZE ; - end = begin +VGA_RAM_SIZE ; - begin = begin &TARGET_PAGE_MASK ; - end = (end +TARGET_PAGE_SIZE -1 ) &TARGET_PAGE_MASK ; - nr_extents = (end - begin) >>TARGET_PAGE_BITS ; +fprintf (logfile,"unmapping vram from %lx - %lx\n" , begin, end); - extent_start =malloc (sizeof (xen_pfn_t) * nr_extents); + xrfp.domid = domid; -if (extent_start ==NULL ) { -fprintf (stderr,"Failed malloc on set_mm_mapping\n" ); -return -1 ; +for (i =0 ; i < (end - begin) >>TARGET_PAGE_BITS ; i++) { + xrfp.gpfn = (begin >>TARGET_PAGE_BITS ) + i; + rc =xc_memory_op (xc_handle, XENMEM_remove_from_physmap, &xrfp); +if (rc) { +fprintf (stderr,"remove_from_physmap PFN %" PRI_xen_pfn" failed: %d\n" , xrfp.gpfn, rc); +return ; + } + } } +} -/* Drop our own references to the vram pages */ -munmap (mapping, nr_extents *TARGET_PAGE_SIZE ); - -/* Now drop the guest's mappings */ -memset (extent_start,0 ,sizeof (xen_pfn_t) * nr_extents); -for (i =0 ; i < nr_extents; i++) - extent_start[i] = (begin + (i *TARGET_PAGE_SIZE )) >>TARGET_PAGE_BITS ; -unset_mm_mapping (xc_handle, domid, nr_extents,0 , extent_start); - -free (extent_start); - -return 0 ; +void cirrus_restart_acc (CirrusVGAState *s) +{ +set_vram_mapping (s, s->lfb_addr, s->lfb_end); + s->map_addr = s->lfb_addr; + s->map_end = s->lfb_end; }/* Compute the memory access functions */
@@ -2783,17 +2728,7 @@ static void cirrus_update_memory_access(CirrusVGAState *s) mode = s->gr[0x05 ] &0x7 ;if (mode <4 || mode >5 || ((s->gr[0x0B ] &0x4 ) ==0 )) {if (s->lfb_addr && s->lfb_end && !s->map_addr) { -void *vram_pointer, *old_vram; - - vram_pointer =set_vram_mapping (s->lfb_addr, - s->lfb_end); -if (!vram_pointer) -fprintf (stderr,"NULL vram_pointer\n" ); -else { - old_vram =vga_update_vram ((VGAState *)s, vram_pointer, -VGA_RAM_SIZE ); -qemu_free (old_vram); - } +set_vram_mapping (s, s->lfb_addr, s->lfb_end); s->map_addr = s->lfb_addr; s->map_end = s->lfb_end; }
@@ -2803,14 +2738,7 @@ static void cirrus_update_memory_access(CirrusVGAState *s) }else { generic_io:if (s->lfb_addr && s->lfb_end && s->map_addr) { -void *old_vram; - - old_vram =vga_update_vram ((VGAState *)s,NULL ,VGA_RAM_SIZE ); - -unset_vram_mapping (s->lfb_addr, - s->lfb_end, - old_vram); - +unset_vram_mapping (s, s->map_addr, s->map_end); s->map_addr = s->map_end =0 ; } s->cirrus_linear_write[0 ] = cirrus_linear_writeb;
@@ -3169,36 +3097,6 @@ static CPUWriteMemoryFunc *cirrus_mmio_write[3] = { cirrus_mmio_writel, }; -void cirrus_stop_acc (CirrusVGAState *s) -{ -if (s->map_addr){ -int error; - s->map_addr =0 ; - error =unset_vram_mapping (s->lfb_addr, - s->lfb_end, s->vram_ptr); -fprintf (stderr,"cirrus_stop_acc:unset_vram_mapping.\n" ); - } -} - -void cirrus_restart_acc (CirrusVGAState *s) -{ -if (s->lfb_addr && s->lfb_end) { -void *vram_pointer, *old_vram; -fprintf (stderr,"cirrus_vga_load:re-enable vga acc.lfb_addr=0x%lx, lfb_end=0x%lx.\n" , - s->lfb_addr, s->lfb_end); - vram_pointer =set_vram_mapping (s->lfb_addr ,s->lfb_end); -if (!vram_pointer){ -fprintf (stderr,"cirrus_vga_load:NULL vram_pointer\n" ); - }else { - old_vram =vga_update_vram ((VGAState *)s, vram_pointer, -VGA_RAM_SIZE ); -qemu_free (old_vram); - s->map_addr = s->lfb_addr; - s->map_end = s->lfb_end; - } - } -} -/* load/save state */ static void cirrus_vga_save (QEMUFile *f,void *opaque)
@@ -3247,7 +3145,10 @@ static void cirrus_vga_save(QEMUFile *f, void *opaque)qemu_put_8s (f, &vga_acc);qemu_put_be64s (f, (uint64_t *)&s->lfb_addr);qemu_put_be64s (f, (uint64_t *)&s->lfb_end); -qemu_put_buffer (f, s->vram_ptr,VGA_RAM_SIZE ); +qemu_put_be64s (f, &s->stolen_vram_addr); +if (!s->stolen_vram_addr && !vga_acc) +/* Old guest: VRAM is not mapped, we have to save it ourselves */ +qemu_put_buffer (f, s->vram_ptr,VGA_RAM_SIZE ); }static int cirrus_vga_load (QEMUFile *f,void *opaque,int version_id)
@@ -3256,7 +3157,7 @@ static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)uint8_t vga_acc =0 ;int ret; -if (version_id >2 ) +if (version_id >3 )return -EINVAL ;if (s->pci_dev && version_id >=2 ) {
@@ -3302,9 +3203,20 @@ static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)qemu_get_8s (f, &vga_acc);qemu_get_be64s (f, (uint64_t *)&s->lfb_addr);qemu_get_be64s (f, (uint64_t *)&s->lfb_end); -qemu_get_buffer (f, s->vram_ptr,VGA_RAM_SIZE ); -if (vga_acc){ -cirrus_restart_acc (s); +if (version_id >=3 ) { +qemu_get_be64s (f, &s->stolen_vram_addr); +if (!s->stolen_vram_addr && !vga_acc) { +/* Old guest, VRAM is not mapped, we have to restore it ourselves */ +qemu_get_buffer (f, s->vram_ptr,VGA_RAM_SIZE ); +xen_vga_populate_vram (s->lfb_addr); + }else +xen_vga_vram_map (vga_acc ? s->lfb_addr : s->stolen_vram_addr,0 ); + }else { +/* Old image, we have to populate and restore VRAM ourselves */ +xen_vga_populate_vram (s->lfb_addr); +qemu_get_buffer (f, s->vram_ptr,VGA_RAM_SIZE ); +if (vga_acc) +cirrus_restart_acc (s); }/* force refresh */
@@ -3426,7 +3338,7 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci) s->cursor_invalidate = cirrus_cursor_invalidate; s->cursor_draw_line = cirrus_cursor_draw_line; -register_savevm ("cirrus_vga" ,0 ,2 , cirrus_vga_save, cirrus_vga_load, s); +register_savevm ("cirrus_vga" ,0 ,3 , cirrus_vga_save, cirrus_vga_load, s); }/***************************************
hw/vga.c +114 -38
200 lines not on this page · raw message
hw/vga_int.h +2 -2
@@ -80,9 +80,9 @@#define VGA_MAX_HEIGHT 2048#define VGA_STATE_COMMON \ - uint8_t *vram_alloc; \ uint8_t *vram_ptr; \ - uint8_t *vram_shadow; \ + xen_pfn_t *vram_mfns; \ + uint64_t stolen_vram_addr;/* Address of stolen RAM */ \unsigned long vram_offset; \unsigned int vram_size; \unsigned long bios_offset; \
hw/xen_platform.c +38 -0
@@ -37,6 +37,7 @@ typedef struct PCIXenPlatformState {PCIDevice pci_dev;uint8_t platform_flags; +uint64_t vga_stolen_ram; } PCIXenPlatformState;static uint32_t xen_platform_ioport_readb (void *opaque,uint32_t addr)
@@ -72,11 +73,46 @@ static void xen_platform_ioport_writeb(void *opaque, uint32_t addr, uint32_t val } +static uint32_t xen_platform_ioport_readl (void *opaque,uint32_t addr) +{ +PCIXenPlatformState *d = opaque; + + addr &=0xff ; + +switch (addr) { +case 4 :/* VGA stolen memory address */ +return d->vga_stolen_ram; +default : +return ~0u ; + } +} + +static void xen_platform_ioport_writel (void *opaque,uint32_t addr,uint32_t val) +{ +PCIXenPlatformState *d = opaque; + + addr &=0xff ; + val &=0xffffffff ; + +switch (addr) { +case 4 :/* VGA stolen memory address */ + d->vga_stolen_ram = val; +xen_vga_stolen_vram_addr (val); +break ; +default : +break ; + } +} + + +static void platform_ioport_map (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) {PCIXenPlatformState *d = (PCIXenPlatformState *)pci_dev;register_ioport_write (addr, size,1 , xen_platform_ioport_writeb, d); +register_ioport_write (addr, size,4 , xen_platform_ioport_writel, d);register_ioport_read (addr, size,1 , xen_platform_ioport_readb, d); +register_ioport_read (addr, size,4 , xen_platform_ioport_readl, d); }static uint32_t platform_mmio_read (void *opaque,target_phys_addr_t addr)
@@ -158,6 +194,7 @@ void xen_pci_save(QEMUFile *f, void *opaque)pci_device_save (&d->pci_dev, f);qemu_put_8s (f, &d->platform_flags); +qemu_put_be64s (f, &d->vga_stolen_ram); }int xen_pci_load (QEMUFile *f,void *opaque,int version_id)
@@ -176,6 +213,7 @@ int xen_pci_load(QEMUFile *f, void *opaque, int version_id)uint8_t flags;qemu_get_8s (f, &flags);xen_platform_ioport_writeb (d,0 , flags); +qemu_get_be64s (f, &d->vga_stolen_ram); }return 0 ;
qemu-xen.h +4 -0
@@ -23,6 +23,10 @@ void timeoffset_get(void);void pci_xen_platform_init (PCIBus *bus);#endif +/* vga.c */ +void xen_vga_stolen_vram_addr (uint64_t vram_addr); +void xen_vga_populate_vram (uint64_t vram_addr); +void xen_vga_vram_map (uint64_t vram_addr,int copy);void destroy_hvm_domain (void );
Quoted 9 lines · Samuel Thibault
Hello,
Quoted 5 lines · Keir Fraser, le Thu 11 Sep 2008 16:54:51 +0100, a écrit :
With patches just submitted to allow stubdom to work with the new out-of-tree qemu-xen-unstable.git, I think the final obstacle to removing the in-tree ioemu has disappeared. I therefore plan to delete the internal ioemu tree early next week unless anyone has a strong reason to delay this action.
Quoted 5 lines
C/S 18383 still needs to be applied to the qemu-xen tree, here is a port.
Samuel
It was applied this morning by Ian.
It would be really nice if the default build process ensured that all external bits were (or at least could be) pre-downloaded and that all necessary tools (git?) were present.
After >30min of "make world" time, I am waiting while the stubdom makefile is trying to wget newlib from sources.redhat.com... and failing repeatedly. (Other downloads worked, so its not a proxy problem.) I am hesitant to interrupt as I'm not sure if I will need to start the build over again.
Risking topic drift... is stubdom required in 3.3 and unstable? If not, is there (or should there be) some easy way to turn it off from the make command line, to avoid all of the wgets?
Quoted 26 lines
-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Thursday, September 11, 2008 9:55 AM
To: xen-devel
Subject: [Xen-devel] ANNOUNCE: Removing in-tree ioemu from xen-unstable.hgWith patches just submitted to allow stubdom to work with the new out-of-tree qemu-xen-unstable.git, I think the final obstacle to removing
the in-tree ioemu has disappeared. I therefore plan to delete the internal
ioemu tree early next week unless anyone has a strong reason to delay this
action.-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines
Risking topic drift... is stubdom required in 3.3 and unstable? If not, is there (or should there be) some easy way to turn it off from the make command line, to avoid all of the wgets?
Stubdom isn't required in xen-unstable yet, but folk should be strongly encouraged to start using it.
However, with stubdom enabled you do lose USB support in qemu-dm right now. The USB PV work that Fujitsu are doing will help fix this.
Thanks,
Ian
Hi,
I have a request about git web page like follows.
http://xenbits.xensource.com/git-http/qemu-xen-unstable.git/
Please use gitweb or any other WebUI package.
http://git.or.cz/gitwiki/Gitweb
Since It can see the log and patches very easily.
Thanks
Atsushi SAKAI
Quoted 14 lines · Keir Fraser
With patches just submitted to allow stubdom to work with the new out-of-tree qemu-xen-unstable.git, I think the final obstacle to removing the in-tree ioemu has disappeared. I therefore plan to delete the internal ioemu tree early next week unless anyone has a strong reason to delay this action.
-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi.
It would be very nice to arrange to send mails to the xen-changelog mailing list when commiting to qemu-xen-unstable.git.
thanks,
Quoted 15 lines · Keir Fraser
With patches just submitted to allow stubdom to work with the new out-of-tree qemu-xen-unstable.git, I think the final obstacle to removing the in-tree ioemu has disappeared. I therefore plan to delete the internal ioemu tree early next week unless anyone has a strong reason to delay this action.
-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Signature · 1 line
yamahata
Daniel Magenheimer writes ("RE: [Xen-devel] ANNOUNCE: Removing in-tree ioemu from xen-unstable.hg"):
Quoted 4 lines
It would be really nice if the default build process ensured that all external bits were (or at least could be) pre-downloaded and that all necessary tools (git?) were present.
This is a good point.
Quoted 6 lines
After >30min of "make world" time, I am waiting while the stubdom makefile is trying to wget newlib from sources.redhat.com... and failing repeatedly. (Other downloads worked, so its not a proxy problem.) I am hesitant to interrupt as I'm not sure if I will need to start the build over again.
Of course some people would prefer to have the computer build what it can while waiting for the downloads.
So how about a separate top-level make target, which does all of the external fetching ? Then you could say
make fetch-remotes
or something.
Quoted 4 lines
Risking topic drift... is stubdom required in 3.3 and unstable? If not, is there (or should there be) some easy way to turn it off from the make command line, to avoid all of the wgets?
It's not required. I don't know if there's a simple way to turn it off from Config.mk but if there isn't I think there should be.
Ian.
Atsushi SAKAI writes ("Re: [Xen-devel] ANNOUNCE: Removing in-tree ioemu from xen-unstable.hg"):
Quoted 2 lines
I have a request about git web page like follows.
http://xenbits.xensource.com/git-http/qemu-xen-unstable.git/
That's not really a web page. It's a URL for a download location useful for git.
Quoted 2 lines
Please use gitweb or any other WebUI package.
http://git.or.cz/gitwiki/Gitweb
We're working on getting a gitweb up. I'll chase it and see if I can increase the priority ...
Quoted 1 line
Since It can see the log and patches very easily.
Quite so.
Ian.
Isaku Yamahata writes ("Re: [Xen-devel] ANNOUNCE: Removing in-tree ioemu from xen-unstable.hg"):
Quoted 2 lines
It would be very nice to arrange to send mails to the xen-changelog mailing list when commiting to qemu-xen-unstable.git.
Good point. I will arrange this.
Ian.
Quoted 7 lines · Ian Jackson, le Fri 12 Sep 2008 10:19:35 +0100, a écrit :
Quoted 4 lines
Risking topic drift... is stubdom required in 3.3 and unstable? If not, is there (or should there be) some easy way to turn it off from the make command line, to avoid all of the wgets?
It's not required. I don't know if there's a simple way to turn it off from Config.mk but if there isn't I think there should be.
It would be just a matter of disabling the stubdom/ recurse from the toplevel Makefile.
Samuel