* [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0
@ 2013-08-30 9:58 Paolo Bonzini
2013-08-30 10:05 ` Paolo Bonzini
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-08-30 9:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
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.
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target-i386/helper.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/target-i386/helper.c b/target-i386/helper.c
index bf3e2ac..7f74e5d 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -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;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0
2013-08-30 9:58 [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0 Paolo Bonzini
@ 2013-08-30 10:05 ` Paolo Bonzini
2013-08-30 17:50 ` Richard Henderson
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-08-30 10:05 UTC (permalink / raw)
To: qemu-stable; +Cc: qemu-devel, Richard Henderson
Il 30/08/2013 11:58, Paolo Bonzini ha scritto:
> 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.
>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> target-i386/helper.c | 34 ++++++++++++++++------------------
> 1 file changed, 16 insertions(+), 18 deletions(-)
>
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index bf3e2ac..7f74e5d 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -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;
> }
>
Should also go in qemu-stable.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0
2013-08-30 9:58 [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0 Paolo Bonzini
2013-08-30 10:05 ` Paolo Bonzini
@ 2013-08-30 17:50 ` Richard Henderson
2013-08-30 18:03 ` Max Filippov
2013-09-12 17:53 ` [Qemu-devel] ping " Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2013-08-30 17:50 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On 08/30/2013 02:58 AM, Paolo Bonzini wrote:
> 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.
>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0
2013-08-30 9:58 [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0 Paolo Bonzini
2013-08-30 10:05 ` Paolo Bonzini
2013-08-30 17:50 ` Richard Henderson
@ 2013-08-30 18:03 ` Max Filippov
2013-09-12 17:53 ` [Qemu-devel] ping " Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2013-08-30 18:03 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, Richard Henderson
On Fri, Aug 30, 2013 at 1:58 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 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.
>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] ping Re: [PATCH] target-i386: fix disassembly with PAE=1, PG=0
2013-08-30 9:58 [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0 Paolo Bonzini
` (2 preceding siblings ...)
2013-08-30 18:03 ` Max Filippov
@ 2013-09-12 17:53 ` Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-09-12 17:53 UTC (permalink / raw)
Cc: qemu-devel, Richard Henderson
Il 30/08/2013 11:58, Paolo Bonzini ha scritto:
> 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.
>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> target-i386/helper.c | 34 ++++++++++++++++------------------
> 1 file changed, 16 insertions(+), 18 deletions(-)
>
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index bf3e2ac..7f74e5d 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -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;
> }
>
Ping!
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-09-12 17:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-30 9:58 [Qemu-devel] [PATCH] target-i386: fix disassembly with PAE=1, PG=0 Paolo Bonzini
2013-08-30 10:05 ` Paolo Bonzini
2013-08-30 17:50 ` Richard Henderson
2013-08-30 18:03 ` Max Filippov
2013-09-12 17:53 ` [Qemu-devel] ping " Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.