Skip to contentSkip to conversation

x86/hvm: Unconditionally buffer writes to VRAM

PATCH In review Paul Durrant 3 participants 5 messages Jul 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hvm: Unconditionally buffer writes to VRAM

When c/s 3bbaaec09 "unify stdvga mmio intercept with standard mmio intercept" was added, a small semantic change was made. Prior to this patch the hypervisor unconditionally sent all guest writes to the VGA aperture as buffered ioreqs, whereas after the patch it only does this when the VGA model is in 'stdvga' mode (sequencer register #7 == 0).

When installing Windows 7 (64-bit) using the default QEMU VGA model (== cirrus), Windows leaves 'stdvga' mode early in boot and hence all further writes to the VGA aperture are done using synchronous ioreqs which slows down boot by several orders of magnitude (thanks to the elaborate splash screen that Windows presents). This can be viewed as a regression and so this patch re-instates previous buffering behaviour.

Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>
---
 xen/arch/x86/hvm/stdvga.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
xen/arch/x86/hvm/stdvga.c +2 -5
index 6d22b22..f50bff7 100644
@@ -441,7 +441,7 @@ static int stdvga_mem_write(const struct hvm_io_handler *handler,
     };
     struct hvm_ioreq_server *srv;
 
-    if ( !s->cache )
+    if ( !s->cache || !s->stdvga )
         goto done;
 
     /* Intercept mmio write */
@@ -503,9 +503,6 @@ static bool_t stdvga_mem_accept(const struct hvm_io_handler *handler,
 
     spin_lock(&s->lock);
 
-    if ( !s->stdvga )
-        goto reject;
-
     if ( p->dir == IOREQ_WRITE && p->count > 1 )
     {
         /*
@@ -526,7 +523,7 @@ static bool_t stdvga_mem_accept(const struct hvm_io_handler *handler,
 
         goto reject;
     }
-    else if ( p->dir == IOREQ_READ && !s->cache )
+    else if ( p->dir == IOREQ_READ && (!s->cache || !s->stdvga) )
         goto reject;
 
     /* s->lock intentionally held */
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Paul Durrant

When c/s 3bbaaec09 "unify stdvga mmio intercept with standard mmio intercept" was added, a small semantic change was made. Prior to this patch the hypervisor unconditionally sent all guest writes to the VGA aperture as buffered ioreqs, whereas after the patch it only does this when the VGA model is in 'stdvga' mode (sequencer register #7 == 0).

When installing Windows 7 (64-bit) using the default QEMU VGA model (== cirrus), Windows leaves 'stdvga' mode early in boot and hence all further writes to the VGA aperture are done using synchronous ioreqs which slows down boot by several orders of magnitude (thanks to the elaborate splash screen that Windows presents). This can be viewed as a regression and so this patch re-instates previous buffering behaviour.

Quoted 5 lines
Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

This is unfortunate, but should be returned to its previous behaviour.

Quoted 36 lines
---
 xen/arch/x86/hvm/stdvga.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
xen/arch/x86/hvm/stdvga.c +2 -5
index 6d22b22..f50bff7 100644
@@ -441,7 +441,7 @@ static int stdvga_mem_write(const struct hvm_io_handler *handler,
     };
     struct hvm_ioreq_server *srv;
 
-    if ( !s->cache )
+    if ( !s->cache || !s->stdvga )
         goto done;
 
     /* Intercept mmio write */
@@ -503,9 +503,6 @@ static bool_t stdvga_mem_accept(const struct hvm_io_handler *handler,
 
     spin_lock(&s->lock);
 
-    if ( !s->stdvga )
-        goto reject;
-
     if ( p->dir == IOREQ_WRITE && p->count > 1 )
     {
         /*
@@ -526,7 +523,7 @@ static bool_t stdvga_mem_accept(const struct hvm_io_handler *handler,
 
         goto reject;
     }
-    else if ( p->dir == IOREQ_READ && !s->cache )
+    else if ( p->dir == IOREQ_READ && (!s->cache || !s->stdvga) )
         goto reject;
 
     /* s->lock intentionally held */
#2 lore raw
Quoted 16 lines · Andrew Cooper
Quoted 15 lines · Paul Durrant

When c/s 3bbaaec09 "unify stdvga mmio intercept with standard mmio intercept" was added, a small semantic change was made. Prior to this patch the hypervisor unconditionally sent all guest writes to the VGA aperture as buffered ioreqs, whereas after the patch it only does this when the VGA model is in 'stdvga' mode (sequencer register #7 == 0).

When installing Windows 7 (64-bit) using the default QEMU VGA model (== cirrus), Windows leaves 'stdvga' mode early in boot and hence all further writes to the VGA aperture are done using synchronous ioreqs which slows down boot by several orders of magnitude (thanks to the elaborate splash screen that Windows presents). This can be viewed as a regression and so this patch re-instates previous buffering behaviour.

Quoted 7 lines
Quoted 5 lines
Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

This is unfortunate,

OOI why is it unfortunate? IOW why wouldn't we want buffer all accesses to the VRAM (leaving aside that perhaps the original authors only intended to do it for StdVGA).

#3 lore raw
Quoted 31 lines

-----Original Message-----
From: Ian Campbell [mailto:[email protected]]
Sent: 16 July 2015 11:13
To: Andrew Cooper
Cc: Paul Durrant; [email protected]; Keir (Xen.org); Jan Beulich
Subject: Re: [Xen-devel] [PATCH (for 4.6)] x86/hvm: Unconditionally buffer writes to VRAM

Quoted 22 lines · Andrew Cooper
Quoted 20 lines · Paul Durrant

When c/s 3bbaaec09 "unify stdvga mmio intercept with standard mmio intercept" was added, a small semantic change was made. Prior to this patch the hypervisor unconditionally sent all guest writes to the VGA aperture as buffered ioreqs, whereas after the patch it only does this when the VGA model is in 'stdvga' mode (sequencer register #7 == 0).

When installing Windows 7 (64-bit) using the default QEMU VGA model (== cirrus), Windows leaves 'stdvga' mode early in boot and hence all further writes to the VGA aperture are done using synchronous ioreqs which slows down boot by several orders of magnitude (thanks to the elaborate splash screen that Windows presents). This can be viewed as a regression and so this patch re-instates previous buffering behaviour.

Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>
Quoted 5 lines
Quoted 1 line

This is unfortunate,

OOI why is it unfortunate? IOW why wouldn't we want buffer all accesses to the VRAM (leaving aside that perhaps the original authors only intended to do it for StdVGA).

Well, VRAM (mapped through a PCI BAR) can't be buffered in general. For instance, the Cirrus model in QEMU re-maps its I/O ports into the first 256 bytes. I think we are ok to always buffer writes to the VGA aperture though as I can't find any obvious side effects (in QEMU's common code).

Paul

Quoted 1 line
#4 lore raw
Quoted 37 lines · Paul Durrant
Quoted 31 lines

-----Original Message-----
From: Ian Campbell [mailto:[email protected]]
Sent: 16 July 2015 11:13
To: Andrew Cooper
Cc: Paul Durrant; [email protected]; Keir (Xen.org); Jan Beulich
Subject: Re: [Xen-devel] [PATCH (for 4.6)] x86/hvm: Unconditionally buffer writes to VRAM

Quoted 22 lines · Andrew Cooper
Quoted 20 lines · Paul Durrant

When c/s 3bbaaec09 "unify stdvga mmio intercept with standard mmio intercept" was added, a small semantic change was made. Prior to this patch the hypervisor unconditionally sent all guest writes to the VGA aperture as buffered ioreqs, whereas after the patch it only does this when the VGA model is in 'stdvga' mode (sequencer register #7 == 0).

When installing Windows 7 (64-bit) using the default QEMU VGA model (== cirrus), Windows leaves 'stdvga' mode early in boot and hence all further writes to the VGA aperture are done using synchronous ioreqs which slows down boot by several orders of magnitude (thanks to the elaborate splash screen that Windows presents). This can be viewed as a regression and so this patch re-instates previous buffering behaviour.

Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>
Quoted 5 lines
Quoted 1 line

This is unfortunate,

OOI why is it unfortunate? IOW why wouldn't we want buffer all accesses to the VRAM (leaving aside that perhaps the original authors only intended to do it for StdVGA).

Quoted 5 lines

Well, VRAM (mapped through a PCI BAR) can't be buffered in general. For instance, the Cirrus model in QEMU re-maps its I/O ports into the first 256 bytes. I think we are ok to always buffer writes to the VGA aperture though as I can't find any obvious side effects (in QEMU's common code).

Ah, so the aperture can contain things other than the framebuffer, makes sense!

Quoted 5 lines

Paul

Quoted 1 line