i386: Catch all non-present ptes in cpu_get_phys_page_debug
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
@@ -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; }
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
@@ -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; }
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
@@ -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; }
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
@@ -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; }
Quoted 23 lines · Jan Kiszka
It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.
Signed-off-by Jan Kiszka <[email protected]>--- 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
-2pte_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
-0pte = pte & env->a20_mask;}
Quoted 31 lines · Anthony Liguori
Quoted 30 lines · Jan Kiszka
It helps debugging guests when yet unmapped pages are correctly reported as, well, unmapped.
Signed-off-by Jan Kiszka <[email protected]>--- 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_MASKtakes 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
@@ -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;
Anthony Liguori
AppliedQuoted 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
Signed-off-by Jan Kiszka <[email protected]>--- 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;