ia64/xen-unstable

changeset 13154:dae6bc4241db

[QEMU] Align VGA ram allocation
This makes the SSE-optimized vram_dirty() safe again.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Thu Dec 21 13:43:19 2006 +0000 (2006-12-21)
parents 5c46e27e3915
children e86605304e52
files tools/ioemu/hw/vga.c tools/ioemu/hw/vga_int.h
line diff
     1.1 --- a/tools/ioemu/hw/vga.c	Thu Dec 21 12:08:27 2006 +0000
     1.2 +++ b/tools/ioemu/hw/vga.c	Thu Dec 21 13:43:19 2006 +0000
     1.3 @@ -2002,7 +2002,10 @@ void vga_common_init(VGAState *s, Displa
     1.4      s->vram_shadow = (uint8_t *)((long)(s->vram_shadow + TARGET_PAGE_SIZE - 1)
     1.5                                   & ~(TARGET_PAGE_SIZE - 1));
     1.6  
     1.7 -    s->vram_ptr = qemu_malloc(vga_ram_size);
     1.8 +    /* Video RAM must be 128-bit aligned for SSE optimizations later */
     1.9 +    s->vram_alloc = qemu_malloc(vga_ram_size + 15);
    1.10 +    s->vram_ptr = (uint8_t *)((long)(s->vram_alloc + 15) & ~15L);
    1.11 +
    1.12      s->vram_offset = vga_ram_offset;
    1.13      s->vram_size = vga_ram_size;
    1.14      s->ds = ds;
    1.15 @@ -2126,7 +2129,7 @@ void *vga_update_vram(VGAState *s, void 
    1.16      }
    1.17  
    1.18      if (!vga_ram_base) {
    1.19 -        vga_ram_base = qemu_malloc(vga_ram_size);
    1.20 +        vga_ram_base = qemu_malloc(vga_ram_size + TARGET_PAGE_SIZE + 1);
    1.21          if (!vga_ram_base) {
    1.22              fprintf(stderr, "reallocate error\n");
    1.23              return NULL;
    1.24 @@ -2134,8 +2137,10 @@ void *vga_update_vram(VGAState *s, void 
    1.25      }
    1.26  
    1.27      /* XXX lock needed? */
    1.28 +    old_pointer = s->vram_alloc;
    1.29 +    s->vram_alloc = vga_ram_base;
    1.30 +    vga_ram_base = (uint8_t *)((long)(vga_ram_base + 15) & ~15L);
    1.31      memcpy(vga_ram_base, s->vram_ptr, vga_ram_size);
    1.32 -    old_pointer = s->vram_ptr;
    1.33      s->vram_ptr = vga_ram_base;
    1.34  
    1.35      return old_pointer;
     2.1 --- a/tools/ioemu/hw/vga_int.h	Thu Dec 21 12:08:27 2006 +0000
     2.2 +++ b/tools/ioemu/hw/vga_int.h	Thu Dec 21 13:43:19 2006 +0000
     2.3 @@ -78,6 +78,7 @@
     2.4  #define VGA_MAX_HEIGHT 2048
     2.5  
     2.6  #define VGA_STATE_COMMON                                                \
     2.7 +    uint8_t *vram_alloc;                                                \
     2.8      uint8_t *vram_ptr;                                                  \
     2.9      uint8_t *vram_shadow;                                               \
    2.10      unsigned long vram_offset;                                          \