Patchwork [2/2] kvm: remove guest triggerable abort()

login
register
mail settings
Submitter Marcelo Tosatti
Date Aug. 10, 2010, 3:12 p.m.
Message ID <14542fea73f294b2a195a8e17c5a0dd15f60640e.1281453126.git.mtosatti@redhat.com>
Download mbox | patch
Permalink /patch/61397/
State New
Headers show

Comments

Marcelo Tosatti - Aug. 10, 2010, 3:12 p.m.
From: Gleb Natapov <gleb@redhat.com>

This abort() condition is easily triggerable by a guest if it configures
pci bar with unaligned address that overlaps main memory.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 kvm-all.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

Patch

diff --git a/kvm-all.c b/kvm-all.c
index 736c516..85f2e58 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -432,18 +432,10 @@  static void kvm_set_phys_mem(target_phys_addr_t start_addr,
     KVMSlot *mem, old;
     int err;
 
-    if (start_addr & ~TARGET_PAGE_MASK) {
-        if (flags >= IO_MEM_UNASSIGNED) {
-            if (!kvm_lookup_overlapping_slot(s, start_addr,
-                                             start_addr + size)) {
-                return;
-            }
-            fprintf(stderr, "Unaligned split of a KVM memory slot\n");
-        } else {
-            fprintf(stderr, "Only page-aligned memory slots supported\n");
-        }
-        abort();
-    }
+    /* kvm works in page size chunks, but the function may be called
+       with sub-page size and unaligned start address. */
+    size = TARGET_PAGE_ALIGN(size);
+    start_addr = TARGET_PAGE_ALIGN(start_addr);
 
     /* KVM does not support read-only slots */
     phys_offset &= ~IO_MEM_ROM;