Skip to contentSkip to conversation

i386: Catch all non-present ptes in cpu_get_phys_page_debug

PATCH Superseded Jan Kiszka 2 participants 7 messages Jun 8, 2008 – Aug 18, 2008

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 i386: Catch all non-present ptes in cpu_get_phys_page_debug

[ Caused some hair pulling here, until I realized that some supposedly corrupted page was not the bug I'm looking for, but a bug in the debug code. ]

---
 target-i386/helper.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
target-i386/helper.c +4 -2
Index: b/target-i386/helper.c
===================================================================
@@ -1174,6 +1174,8 @@ target_phys_addr_t cpu_get_phys_page_deb
             page_size = 4096;
             pte = ldq_phys(pte_addr);
         }
+        if (!(pte & PG_PRESENT_MASK))
+            return -1;
     } else {
         uint32_t pde;
 
@@ -1193,10 +1195,10 @@ target_phys_addr_t cpu_get_phys_page_deb
                 /* page directory entry */
                 pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask;
                 pte = ldl_phys(pte_addr);
-                if (!(pte & PG_PRESENT_MASK))
-                    return -1;
                 page_size = 4096;
             }
+            if (!(pte & PG_PRESENT_MASK))
+                return -1;
         }
         pte = pte & env->a20_mask;
     }
author
#1 lore raw

PATCH RESEND 1/1 i386: Catch all non-present ptes in cpu_get_phys_page_debug

It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.

---
 target-i386/helper.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
target-i386/helper.c +4 -2
Index: b/target-i386/helper.c
===================================================================
@@ -1192,6 +1192,8 @@ target_phys_addr_t cpu_get_phys_page_deb
             page_size = 4096;
             pte = ldq_phys(pte_addr);
         }
+        if (!(pte & PG_PRESENT_MASK))
+            return -1;
     } else {
         uint32_t pde;
 
@@ -1211,10 +1213,10 @@ target_phys_addr_t cpu_get_phys_page_deb
                 /* page directory entry */
                 pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask;
                 pte = ldl_phys(pte_addr);
-                if (!(pte & PG_PRESENT_MASK))
-                    return -1;
                 page_size = 4096;
             }
+            if (!(pte & PG_PRESENT_MASK))
+                return -1;
         }
         pte = pte & env->a20_mask;
     }
author
#2 lore raw

PATCH RESEND 1/1 i386: Catch all non-present ptes in cpu_get_phys_page_debug

It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.

---
 target-i386/helper.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
target-i386/helper.c +4 -2
Index: b/target-i386/helper.c
===================================================================
@@ -1192,6 +1192,8 @@ target_phys_addr_t cpu_get_phys_page_deb
             page_size = 4096;
             pte = ldq_phys(pte_addr);
         }
+        if (!(pte & PG_PRESENT_MASK))
+            return -1;
     } else {
         uint32_t pde;
 
@@ -1211,10 +1213,10 @@ target_phys_addr_t cpu_get_phys_page_deb
                 /* page directory entry */
                 pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask;
                 pte = ldl_phys(pte_addr);
-                if (!(pte & PG_PRESENT_MASK))
-                    return -1;
                 page_size = 4096;
             }
+            if (!(pte & PG_PRESENT_MASK))
+                return -1;
         }
         pte = pte & env->a20_mask;
     }
author
#3 lore raw

PATCH RESEND 1/1 i386: Catch all non-present ptes in cpu_get_phys_page_debug

It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.

---
 target-i386/helper.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
target-i386/helper.c +4 -2
Index: b/target-i386/helper.c
===================================================================
@@ -1192,6 +1192,8 @@ target_phys_addr_t cpu_get_phys_page_deb
             page_size = 4096;
             pte = ldq_phys(pte_addr);
         }
+        if (!(pte & PG_PRESENT_MASK))
+            return -1;
     } else {
         uint32_t pde;
 
@@ -1211,10 +1213,10 @@ target_phys_addr_t cpu_get_phys_page_deb
                 /* page directory entry */
                 pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask;
                 pte = ldl_phys(pte_addr);
-                if (!(pte & PG_PRESENT_MASK))
-                    return -1;
                 page_size = 4096;
             }
+            if (!(pte & PG_PRESENT_MASK))
+                return -1;
         }
         pte = pte & env->a20_mask;
     }
#4 lore raw
Quoted 23 lines · Jan Kiszka

It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.

---
 target-i386/helper.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: b/target-i386/helper.c
===================================================================

target-i386/helper.c +2 -0
@@ -1192,6 +1192,8 @@ target_phys_addr_t cpu_get_phys_page_deb
             page_size = 4096;
             pte = ldq_phys(pte_addr);
         }
+        if (!(pte & PG_PRESENT_MASK))
+            return -1;
     } else {
         uint32_t pde;
 
@@ -1211,10 +1213,10 @@ target_phys_addr_t cpu_get_phys_page_deb
                 /* page directory entry */

target-i386/helper.c target_phys_addr_t cpu_get_phys_page_deb · line 1221

Quoted 10 lines
target-i386/helper.c +2 -2
                 pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask;
                 pte = ldl_phys(pte_addr);
-                if (!(pte & PG_PRESENT_MASK))
-                    return -1;
                 page_size = 4096;
             }
+            if (!(pte & PG_PRESENT_MASK))
+                return -1;
         }
 

This looks redundant. In the PSE=1 case, the check for pde & PG_PRESENT_MASK takes care of it. In the PSE=0 clause, there is already a check for pte & PG_PRESENT_MASK.

The first chunk looks like a genuine fix though.

Regards,

Anthony Liguori

Quoted 5 lines
target-i386/helper.c +0 -0
         pte = pte & env->a20_mask;
     }
author
#5 lore raw
Quoted 31 lines · Anthony Liguori
Quoted 30 lines · Jan Kiszka

It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.

---
 target-i386/helper.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: b/target-i386/helper.c
===================================================================

target-i386/helper.c +2 -2
@@ -1192,6 +1192,8 @@ target_phys_addr_t cpu_get_phys_page_deb
             page_size = 4096;
             pte = ldq_phys(pte_addr);
         }
+        if (!(pte & PG_PRESENT_MASK))
+            return -1;
     } else {
         uint32_t pde;
 
@@ -1211,10 +1213,10 @@ target_phys_addr_t cpu_get_phys_page_deb
                 /* page directory entry */
                 pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc))
 & env->a20_mask;
                 pte = ldl_phys(pte_addr);
-                if (!(pte & PG_PRESENT_MASK))
-                    return -1;
                 page_size = 4096;
             }
Quoted 8 lines

target-i386/helper.c target_phys_addr_t cpu_get_phys_page_deb · line 1222

Quoted 4 lines
target-i386/helper.c +2 -0
+            if (!(pte & PG_PRESENT_MASK))
+                return -1;
         }
 

This looks redundant. In the PSE=1 case, the check for pde & PG_PRESENT_MASK takes care of it. In the PSE=0 clause, there is already a check for pte & PG_PRESENT_MASK.

True.

Quoted 2 lines

The first chunk looks like a genuine fix though.

Here is the stripped-down version:

-----------

It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.

---
 target-i386/helper.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
target-i386/helper.c +2 -0
Index: b/target-i386/helper.c
===================================================================
@@ -1192,6 +1192,8 @@ target_phys_addr_t cpu_get_phys_page_deb
             page_size = 4096;
             pte = ldq_phys(pte_addr);
         }
+        if (!(pte & PG_PRESENT_MASK))
+            return -1;
     } else {
         uint32_t pde;
 
#6 lore raw
Quoted 3 lines · Jan Kiszka

It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 21 lines
---
 target-i386/helper.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: b/target-i386/helper.c
===================================================================

target-i386/helper.c +2 -0
@@ -1192,6 +1192,8 @@ target_phys_addr_t cpu_get_phys_page_deb
             page_size = 4096;
             pte = ldq_phys(pte_addr);
         }
+        if (!(pte & PG_PRESENT_MASK))
+            return -1;
     } else {
         uint32_t pde;