|
|
298366 |
From f9fd82ee939d6ee5bff126b125020021e18ce330 Mon Sep 17 00:00:00 2001
|
|
|
298366 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
298366 |
Date: Fri, 30 Aug 2013 11:58:45 +0200
|
|
|
298366 |
Subject: [PATCH] target-i386: fix disassembly with PAE=1, PG=0
|
|
|
298366 |
|
|
|
298366 |
CR4.PAE=1 will not enable paging if CR0.PG=0, but the "if" chain
|
|
|
298366 |
in x86_cpu_get_phys_page_debug says otherwise. Check CR0.PG
|
|
|
298366 |
before everything else.
|
|
|
298366 |
|
|
|
298366 |
Fixes "-d in_asm" for a code section at the beginning of OVMF.
|
|
|
298366 |
|
|
|
298366 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
298366 |
Signed-off-by: Richard Henderson <rth@twiddle.net>
|
|
|
298366 |
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
|
|
|
298366 |
(cherry picked from commit f2f8560c7a5303065a2a3207ec475dfb3a622a0e)
|
|
|
298366 |
|
|
|
298366 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
298366 |
---
|
|
|
298366 |
target-i386/helper.c | 34 ++++++++++++++++------------------
|
|
|
298366 |
1 file changed, 16 insertions(+), 18 deletions(-)
|
|
|
298366 |
|
|
|
298366 |
diff --git a/target-i386/helper.c b/target-i386/helper.c
|
|
|
298366 |
index bf3e2ac..7f74e5d 100644
|
|
|
298366 |
--- a/target-i386/helper.c
|
|
|
298366 |
+++ b/target-i386/helper.c
|
|
|
298366 |
@@ -894,7 +894,10 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
|
|
|
298366 |
uint32_t page_offset;
|
|
|
298366 |
int page_size;
|
|
|
298366 |
|
|
|
298366 |
- if (env->cr[4] & CR4_PAE_MASK) {
|
|
|
298366 |
+ if (!(env->cr[0] & CR0_PG_MASK)) {
|
|
|
298366 |
+ pte = addr & env->a20_mask;
|
|
|
298366 |
+ page_size = 4096;
|
|
|
298366 |
+ } else if (env->cr[4] & CR4_PAE_MASK) {
|
|
|
298366 |
target_ulong pdpe_addr;
|
|
|
298366 |
uint64_t pde, pdpe;
|
|
|
298366 |
|
|
|
298366 |
@@ -952,26 +955,21 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
|
|
|
298366 |
} else {
|
|
|
298366 |
uint32_t pde;
|
|
|
298366 |
|
|
|
298366 |
- if (!(env->cr[0] & CR0_PG_MASK)) {
|
|
|
298366 |
- pte = addr;
|
|
|
298366 |
- page_size = 4096;
|
|
|
298366 |
+ /* page directory entry */
|
|
|
298366 |
+ pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask;
|
|
|
298366 |
+ pde = ldl_phys(pde_addr);
|
|
|
298366 |
+ if (!(pde & PG_PRESENT_MASK))
|
|
|
298366 |
+ return -1;
|
|
|
298366 |
+ if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
|
|
|
298366 |
+ pte = pde & ~0x003ff000; /* align to 4MB */
|
|
|
298366 |
+ page_size = 4096 * 1024;
|
|
|
298366 |
} else {
|
|
|
298366 |
/* page directory entry */
|
|
|
298366 |
- pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask;
|
|
|
298366 |
- pde = ldl_phys(pde_addr);
|
|
|
298366 |
- if (!(pde & PG_PRESENT_MASK))
|
|
|
298366 |
+ pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask;
|
|
|
298366 |
+ pte = ldl_phys(pte_addr);
|
|
|
298366 |
+ if (!(pte & PG_PRESENT_MASK))
|
|
|
298366 |
return -1;
|
|
|
298366 |
- if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
|
|
|
298366 |
- pte = pde & ~0x003ff000; /* align to 4MB */
|
|
|
298366 |
- page_size = 4096 * 1024;
|
|
|
298366 |
- } else {
|
|
|
298366 |
- /* page directory entry */
|
|
|
298366 |
- pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask;
|
|
|
298366 |
- pte = ldl_phys(pte_addr);
|
|
|
298366 |
- if (!(pte & PG_PRESENT_MASK))
|
|
|
298366 |
- return -1;
|
|
|
298366 |
- page_size = 4096;
|
|
|
298366 |
- }
|
|
|
298366 |
+ page_size = 4096;
|
|
|
298366 |
}
|
|
|
298366 |
pte = pte & env->a20_mask;
|
|
|
298366 |
}
|