Skip to contentSkip to conversation

phys_page_find_alloc: Use correct initial region_offset.

PATCH Applied [email protected] 2 participants 2 messages Dec 13, 2011 – Dec 15, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phys_page_find_alloc: Use correct initial region_offset.

From: Alex Rozenman <[email protected]>

This fixes a common bug with initial region_offset value. Usually, the pages are re-assigned afterwards, so the bug has a very small effect on regular QEMU use flows.

---
 exec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
exec.c +2 -1
index d8b2180..14628d9 100644
@@ -418,6 +418,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
     pd = *lp;
     if (pd == NULL) {
         int i;
+        int first_index = index & ~(L2_SIZE - 1);
 
         if (!alloc) {
             return NULL;
@@ -427,7 +428,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
 
         for (i = 0; i < L2_SIZE; i++) {
             pd[i].phys_offset = IO_MEM_UNASSIGNED;
-            pd[i].region_offset = (index + i) << TARGET_PAGE_BITS;
+            pd[i].region_offset = (first_index + i) << TARGET_PAGE_BITS;
         }
     }
 
Signature · 1 line
1.7.8
#1 lore raw
Quoted 7 lines · On 12/13/2011 04:52 AM, [email protected] wrote:

From: Alex Rozenman<[email protected]>

This fixes a common bug with initial region_offset value. Usually, the pages are re-assigned afterwards, so the bug has a very small effect on regular QEMU use flows.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 25 lines
---
  exec.c |    3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)
exec.c +2 -1
index d8b2180..14628d9 100644
@@ -418,6 +418,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
      pd = *lp;
      if (pd == NULL) {
          int i;
+        int first_index = index&  ~(L2_SIZE - 1);
 
          if (!alloc) {
              return NULL;
@@ -427,7 +428,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
 
          for (i = 0; i<  L2_SIZE; i++) {
              pd[i].phys_offset = IO_MEM_UNASSIGNED;
-            pd[i].region_offset = (index + i)<<  TARGET_PAGE_BITS;
+            pd[i].region_offset = (first_index + i)<<  TARGET_PAGE_BITS;
          }
      }