Skip to contentSkip to conversation

x86/hvm: make sure stdvga cache cannot be re-enabled

PATCH New Paul Durrant 1 participant 1 message Nov 5, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/hvm: make sure stdvga cache cannot be re-enabled

As soon as the cache is disabled, it will become out-of-sync with the VGA device model and since no mechanism exists to acquire current VRAM state from the device model, re-enabling it leads to stale data being seen by the guest.

The problem was introduced by commit 3bbaaec0 ("x86/hvm: unify stdvga mmio intercept with standard mmio intercept") and can be seen by deliberately crashing a Windows guest; the BSOD output is corrupted.

This patch changes the existing 'cache' boolean in hvm_hw_stdvga into a tri-state enum and only allows the state to move from 'uninitialized' to 'enabled'. Once the cache state becomes 'disabled' it will remain so for the lifetime of the VM.

---
 xen/arch/x86/hvm/save.c      |  2 +-
 xen/arch/x86/hvm/stdvga.c    | 50 ++++++++++++++++++++++++++++++++------------
 xen/include/asm-x86/hvm/io.h |  8 ++++++-
 3 files changed, 45 insertions(+), 15 deletions(-)
xen/arch/x86/hvm/save.c +1 -1
index 4660beb..f7d4999 100644
@@ -73,7 +73,7 @@ int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr)
     d->arch.hvm_domain.sync_tsc = rdtsc();
 
     /* VGA state is not saved/restored, so we nobble the cache. */
-    d->arch.hvm_domain.stdvga.cache = 0;
+    d->arch.hvm_domain.stdvga.cache = STDVGA_CACHE_DISABLED;
 
     return 0;
 }
xen/arch/x86/hvm/stdvga.c +37 -13

77 lines not on this page · raw message

xen/include/asm-x86/hvm/io.h +7 -1
index 8585a1f..ceefa2e 100644
@@ -128,13 +128,19 @@ void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq,
 void msix_write_completion(struct vcpu *);
 void msixtbl_init(struct domain *d);
 
+enum stdvga_cache_state {
+    STDVGA_CACHE_UNINITIALIZED,
+    STDVGA_CACHE_ENABLED,
+    STDVGA_CACHE_DISABLED
+};
+
 struct hvm_hw_stdvga {
     uint8_t sr_index;
     uint8_t sr[8];
     uint8_t gr_index;
     uint8_t gr[9];
     bool_t stdvga;
-    bool_t cache;
+    enum stdvga_cache_state cache;
     uint32_t latch;
     struct page_info *vram_page[64];  /* shadow of 0xa0000-0xaffff */
     spinlock_t lock;
Signature · 1 line
2.1.4