ia64/xen-unstable

changeset 13849:8bc64a3a5054

[QEMU] Unmap video RAM before telling the guest to free it.
This avoids a lot of "freeing in-use page" errors.

Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Mon Feb 05 16:40:19 2007 +0000 (2007-02-05)
parents e825954d4179
children ffe95edc5266
files tools/ioemu/hw/cirrus_vga.c
line diff
     1.1 --- a/tools/ioemu/hw/cirrus_vga.c	Mon Feb 05 15:08:18 2007 +0000
     1.2 +++ b/tools/ioemu/hw/cirrus_vga.c	Mon Feb 05 16:40:19 2007 +0000
     1.3 @@ -2571,7 +2571,8 @@ static void *set_vram_mapping(unsigned l
     1.4      return vram_pointer;
     1.5  }
     1.6  
     1.7 -static int unset_vram_mapping(unsigned long begin, unsigned long end)
     1.8 +static int unset_vram_mapping(unsigned long begin, unsigned long end, 
     1.9 +                              void *mapping)
    1.10  {
    1.11      xen_pfn_t *extent_start = NULL;
    1.12      unsigned long nr_extents;
    1.13 @@ -2591,11 +2592,13 @@ static int unset_vram_mapping(unsigned l
    1.14          return -1;
    1.15      }
    1.16  
    1.17 +    /* Drop our own references to the vram pages */
    1.18 +    munmap(mapping, nr_extents * TARGET_PAGE_SIZE);
    1.19 +
    1.20 +    /* Now drop the guest's mappings */
    1.21      memset(extent_start, 0, sizeof(xen_pfn_t) * nr_extents);
    1.22 -
    1.23      for (i = 0; i < nr_extents; i++)
    1.24          extent_start[i] = (begin + (i * TARGET_PAGE_SIZE)) >> TARGET_PAGE_BITS;
    1.25 -
    1.26      unset_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
    1.27  
    1.28      free(extent_start);
    1.29 @@ -2642,16 +2645,14 @@ static void cirrus_update_memory_access(
    1.30          } else {
    1.31          generic_io:
    1.32              if (s->cirrus_lfb_addr && s->cirrus_lfb_end && s->map_addr) {
    1.33 -		int error;
    1.34 -                void *old_vram = NULL;
    1.35 -
    1.36 -		error = unset_vram_mapping(s->cirrus_lfb_addr,
    1.37 -					   s->cirrus_lfb_end);
    1.38 -		if (!error)
    1.39 -		    old_vram = vga_update_vram((VGAState *)s, NULL,
    1.40 -                                               VGA_RAM_SIZE);
    1.41 -                if (old_vram)
    1.42 -                    munmap(old_vram, s->map_addr - s->map_end);
    1.43 +                void *old_vram;
    1.44 +
    1.45 +                old_vram = vga_update_vram((VGAState *)s, NULL, VGA_RAM_SIZE);
    1.46 +
    1.47 +                unset_vram_mapping(s->cirrus_lfb_addr,
    1.48 +                                   s->cirrus_lfb_end, 
    1.49 +                                   old_vram);
    1.50 +
    1.51                  s->map_addr = s->map_end = 0;
    1.52              }
    1.53              s->cirrus_linear_write[0] = cirrus_linear_writeb;
    1.54 @@ -3016,10 +3017,8 @@ void cirrus_stop_acc(CirrusVGAState *s)
    1.55          int error;
    1.56          s->map_addr = 0;
    1.57          error = unset_vram_mapping(s->cirrus_lfb_addr,
    1.58 -                s->cirrus_lfb_end);
    1.59 +                s->cirrus_lfb_end, s->vram_ptr);
    1.60          fprintf(stderr, "cirrus_stop_acc:unset_vram_mapping.\n");
    1.61 -
    1.62 -        munmap(s->vram_ptr, VGA_RAM_SIZE);
    1.63      }
    1.64  }
    1.65