target-i386: fix disassembly with PAE=1, PG=0
PATCH 1/1 target-i386: fix disassembly with PAE=1, PG=0
CR4.PAE=1 will not enable paging if CR0.PG=0, but the "if" chain in x86_cpu_get_phys_page_debug says otherwise. Check CR0.PG before everything else.
Fixes "-d in_asm" for a code section at the beginning of OVMF.
--- target-i386/helper.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)
target-i386/helper.c +16 -18
@@ -894,7 +894,10 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)uint32_t page_offset;int page_size; -if (env->cr[4 ] &CR4_PAE_MASK ) { +if (!(env->cr[0 ] &CR0_PG_MASK )) { + pte = addr & env->a20_mask; + page_size =4096 ; + }else if (env->cr[4 ] &CR4_PAE_MASK ) {target_ulong pdpe_addr;uint64_t pde, pdpe;
@@ -952,26 +955,21 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }else {uint32_t pde; -if (!(env->cr[0 ] &CR0_PG_MASK )) { - pte = addr; - page_size =4096 ; +/* page directory entry */ + pde_addr = ((env->cr[3 ] & ~0xfff ) + ((addr >>20 ) &0xffc )) & env->a20_mask; + pde =ldl_phys (pde_addr); +if (!(pde &PG_PRESENT_MASK )) +return -1 ; +if ((pde &PG_PSE_MASK ) && (env->cr[4 ] &CR4_PSE_MASK )) { + pte = pde & ~0x003ff000 ;/* align to 4MB */ + page_size =4096 *1024 ; }else {/* page directory entry */ - pde_addr = ((env->cr[3 ] & ~0xfff ) + ((addr >>20 ) &0xffc )) & env->a20_mask; - pde =ldl_phys (pde_addr); -if (!(pde &PG_PRESENT_MASK )) + pte_addr = ((pde & ~0xfff ) + ((addr >>10 ) &0xffc )) & env->a20_mask; + pte =ldl_phys (pte_addr); +if (!(pte &PG_PRESENT_MASK ))return -1 ; -if ((pde &PG_PSE_MASK ) && (env->cr[4 ] &CR4_PSE_MASK )) { - pte = pde & ~0x003ff000 ;/* align to 4MB */ - page_size =4096 *1024 ; - }else { -/* 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 ; - } + page_size =4096 ; } pte = pte & env->a20_mask; }
Signature · 1 line
1.8.3.1
Il 30/08/2013 11:58, Paolo Bonzini ha scritto:
Quoted 58 lines
CR4.PAE=1 will not enable paging if CR0.PG=0, but the "if" chain in
x86_cpu_get_phys_page_debugsays otherwise. Check CR0.PG before everything else.Fixes "-d
in_asm" for a code section at the beginning of OVMF.Cc Richard Henderson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- target-i386/helper.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)target-i386/helper.c +15
-12@@ -894,7 +894,10 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)uint32_t page_offset;int page_size; -if (env->cr[4 ] &CR4_PAE_MASK ) { +if (!(env->cr[0 ] &CR0_PG_MASK )) { + pte = addr & env->a20_mask; + page_size =4096 ; + }else if (env->cr[4 ] &CR4_PAE_MASK ) {target_ulong pdpe_addr;uint64_t pde, pdpe;@@ -952,26 +955,21 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }else {uint32_t pde; -if (!(env->cr[0 ] &CR0_PG_MASK )) { - pte = addr; - page_size =4096 ; +/* page directory entry */ + pde_addr = ((env->cr[3 ] & ~0xfff ) + ((addr >>20 ) &0xffc )) & env->a20_mask; + pde =ldl_phys (pde_addr); +if (!(pde &PG_PRESENT_MASK )) +return -1 ; +if ((pde &PG_PSE_MASK ) && (env->cr[4 ] &CR4_PSE_MASK )) { + pte = pde & ~0x003ff000 ;/* align to 4MB */ + page_size =4096 *1024 ; }else {/* page directory entry */ - pde_addr = ((env->cr[3 ] & ~0xfff ) + ((addr >>20 ) &0xffc )) & env->a20_mask; - pde =ldl_phys (pde_addr); -if (!(pde &PG_PRESENT_MASK )) + pte_addr = ((pde & ~0xfff ) + ((addr >>10 ) &0xffc )) & env->a20_mask; + pte =ldl_phys (pte_addr); +if (!(pte &PG_PRESENT_MASK ))return -1 ; -if ((pde &PG_PSE_MASK ) && (env->cr[4 ] &CR4_PSE_MASK )) { - pte = pde & ~0x003ff000 ;/* align to 4MB */ - page_size =4096 *1024 ; - }else { -/* page directory entry */
target-i386/helper.c hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) · line 975
Quoted 10 lines
target-i386/helper.c +1
-6- 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 ; - } + page_size =4096 ; } pte = pte & env->a20_mask; }
Should also go in qemu-stable.
Paolo
Quoted 8 lines · Paolo Bonzini
CR4.PAE=1 will not enable paging if CR0.PG=0, but the "if" chain in
x86_cpu_get_phys_page_debugsays otherwise. Check CR0.PG before everything else.Fixes "-d
in_asm" for a code section at the beginning of OVMF.Cc Richard Henderson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>
r~
Quoted 11 lines · Paolo Bonzini
CR4.PAE=1 will not enable paging if CR0.PG=0, but the "if" chain in
x86_cpu_get_phys_page_debugsays otherwise. Check CR0.PG before everything else.Fixes "-d
in_asm" for a code section at the beginning of OVMF.Cc Richard Henderson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- target-i386/helper.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)
Hmmm, déjà vu: http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg01635.html
Signature · 2 lines
Thanks. -- Max
[Qemu-devel] ping Re: [PATCH] target-i386: fix disassembly with PAE=1, PG=0
In reply to Paolo BonziniIl 30/08/2013 11:58, Paolo Bonzini ha scritto:
Quoted 58 lines
CR4.PAE=1 will not enable paging if CR0.PG=0, but the "if" chain in
x86_cpu_get_phys_page_debugsays otherwise. Check CR0.PG before everything else.Fixes "-d
in_asm" for a code section at the beginning of OVMF.Cc Richard Henderson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- target-i386/helper.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)target-i386/helper.c +15
-12@@ -894,7 +894,10 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)uint32_t page_offset;int page_size; -if (env->cr[4 ] &CR4_PAE_MASK ) { +if (!(env->cr[0 ] &CR0_PG_MASK )) { + pte = addr & env->a20_mask; + page_size =4096 ; + }else if (env->cr[4 ] &CR4_PAE_MASK ) {target_ulong pdpe_addr;uint64_t pde, pdpe;@@ -952,26 +955,21 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }else {uint32_t pde; -if (!(env->cr[0 ] &CR0_PG_MASK )) { - pte = addr; - page_size =4096 ; +/* page directory entry */ + pde_addr = ((env->cr[3 ] & ~0xfff ) + ((addr >>20 ) &0xffc )) & env->a20_mask; + pde =ldl_phys (pde_addr); +if (!(pde &PG_PRESENT_MASK )) +return -1 ; +if ((pde &PG_PSE_MASK ) && (env->cr[4 ] &CR4_PSE_MASK )) { + pte = pde & ~0x003ff000 ;/* align to 4MB */ + page_size =4096 *1024 ; }else {/* page directory entry */ - pde_addr = ((env->cr[3 ] & ~0xfff ) + ((addr >>20 ) &0xffc )) & env->a20_mask; - pde =ldl_phys (pde_addr); -if (!(pde &PG_PRESENT_MASK )) + pte_addr = ((pde & ~0xfff ) + ((addr >>10 ) &0xffc )) & env->a20_mask; + pte =ldl_phys (pte_addr); +if (!(pte &PG_PRESENT_MASK ))return -1 ; -if ((pde &PG_PSE_MASK ) && (env->cr[4 ] &CR4_PSE_MASK )) { - pte = pde & ~0x003ff000 ;/* align to 4MB */ - page_size =4096 *1024 ; - }else { -/* page directory entry */
target-i386/helper.c hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) · line 975
Quoted 10 lines
target-i386/helper.c +1
-6- 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 ; - } + page_size =4096 ; } pte = pte & env->a20_mask; }
Ping!
Paolo