diff mbox

[10/17] Support unregistering memory regions larger than a slot

Message ID 1242574999-20887-11-git-send-email-aliguori@us.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anthony Liguori May 17, 2009, 3:43 p.m. UTC
From: Avi Kivity <avi@redhat.com>

Unbreaks vga text mode after switching from graphics mode.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Comments

Avi Kivity May 17, 2009, 5:03 p.m. UTC | #1
Anthony Liguori wrote:
> From: Avi Kivity <avi@redhat.com>
>
> Unbreaks vga text mode after switching from graphics mode.
>
>   

I think this was caused by a merge (and indeed the immediately preceding 
commit is a merge), so this is likely unneeded.
Jan Kiszka May 18, 2009, 2:23 p.m. UTC | #2
Avi Kivity wrote:
> Anthony Liguori wrote:
>> From: Avi Kivity <avi@redhat.com>
>>
>> Unbreaks vga text mode after switching from graphics mode.
>>
>>   
> 
> I think this was caused by a merge (and indeed the immediately preceding
> commit is a merge), so this is likely unneeded.
> 

Nope, it also fixes the long-standing text mode corruption after reset
out of graphic mode.

Jan
diff mbox

Patch

diff --git a/qemu-kvm.c b/qemu-kvm.c
index fab00ac..10e2caa 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -889,14 +889,15 @@  void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
                                       unsigned long phys_offset)
 {
     int r = 0;
-    unsigned long area_flags = phys_offset & ~TARGET_PAGE_MASK;
+    unsigned long area_flags;
 #ifdef TARGET_I386
     struct mapping *p;
 #endif
 
     phys_offset &= ~IO_MEM_ROM;
+    area_flags = phys_offset & ~TARGET_PAGE_MASK;
 
-    if (area_flags == IO_MEM_UNASSIGNED) {
+    if (area_flags != IO_MEM_RAM) {
 #ifdef TARGET_I386
         if (must_use_aliases_source(start_addr)) {
             kvm_destroy_memory_alias(kvm_context, start_addr);
@@ -905,7 +906,19 @@  void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
         if (must_use_aliases_target(start_addr))
             return;
 #endif
-        kvm_unregister_memory_area(kvm_context, start_addr, size);
+        while (size > 0) {
+            p = find_mapping(start_addr);
+            if (p) {
+                kvm_unregister_memory_area(kvm_context, p->phys, p->len);
+                drop_mapping(p->phys);
+            }
+            start_addr += TARGET_PAGE_SIZE;
+            if (size > TARGET_PAGE_SIZE) {
+                size -= TARGET_PAGE_SIZE;
+            } else {
+                size = 0;
+            }
+        }
         return;
     }