[4239] x86/x86-64 MMU PAE fixes
Revision: 4239
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4239 Author: aurel32 Date: 2008-04-22 20:37:43 +0000 (Tue, 22 Apr 2008)
Log Message:
-----------
x86/x86-64 MMU PAE fixes
This patch fixes MMU emulation in PAE mode for > 4GB physical addresses:
- a20_mask should have the correct size to not clear the high part of the addresses.
- PHYS_ADDR_MASK should not clear the high part of the addresses.
- pdpe, pde and pte could be located anywhere in memory on x86-64, but only in the first 4GB on x86, define their pointer to as target_ulong.
- pml4e_addr could be located anywhere in memory, define its pointer as uint64_t.
- paddr represents a physical address and thus should be of type target_phys_addr_t.
Modified Paths:
--------------
trunk/target-i386/cpu.h
trunk/target-i386/helper2.cModified: trunk/target-i386/cpu.h
===================================================================
target-i386/cpu.h +1 -1
@@ -499,7 +499,7 @@SegmentCache idt;/* only base and limit are used */ target_ulong cr[9 ];/* NOTE: cr1, cr5-7 are unused */ -uint32_t a20_mask; +uint64_t a20_mask;/* FPU state */ unsigned int fpstt;/* top of stack index */
Modified: trunk/target-i386/helper2.c
===================================================================
target-i386/helper2.c +23 -19
118 lines not on this page · raw message
target-i386/helper2.c line 803
Quoted 2 lines · Aurelien Jarno
target-i386/helper2.c +1
-1-#define PHYS_ADDR_MASK 0xfffff000 +#define PHYS_ADDR_MASK (~0xfff)
I think this is wrong. According to my docs physical addresses have an architectural limit of 52 bits. Bits 52-62 of a PTE are reserved (must be zero), and bit 63 is the NX bit.
You already reverted the following, but I'm going to mention it anyway:
Review
Quoted 2 lines
(quoted diff) +0
-2-#elif defined(TARGET_X86_64) && !defined(USE_KQEMU) -#define TARGET_PHYS_ADDR_SPACE_BITS 40
I think this should either be 52, or cpu specific.
Paul
Quoted 7 lines · Paul Brook
target-i386/helper2.c line 803
Quoted 2 lines · Aurelien Jarno
target-i386/helper2.c +1
-1-#define PHYS_ADDR_MASK 0xfffff000 +#define PHYS_ADDR_MASK (~0xfff)I think this is wrong. According to my docs physical addresses have an architectural limit of 52 bits. Bits 52-62 of a PTE are reserved (must be zero), and bit 63 is the NX bit.
The documentation I'm using:
"Intel 64 and IA-32 Architectures Software Development Manual,
Volume 3A: System Programming Guide, Part 1"
"3.8 36-Bit Physical Addressing Using The PAE Paging Mechanism"
Lists bits 36-63 as "must be zero".
(For i386, or x86_64 running in 32-bit mode.)
"3.10 PAE-Enabled Paging in IA-32e Mode"
Lists bits 40-51 as "must be zero".
Lists bits 52 to 62 as "available".
Lists bit 63 as "EXB" (i.e. the NX bit).
(For x86_64 running in 64-bit mode.)
HTH,
Signature · 1 line
Stuart Brady
Quoted 9 lines · Stuart Brady
Quoted 7 lines · Paul Brook
target-i386/helper2.c line 803
Quoted 2 lines · Aurelien Jarno
target-i386/helper2.c +1
-1-#define PHYS_ADDR_MASK 0xfffff000 +#define PHYS_ADDR_MASK (~0xfff)I think this is wrong. According to my docs physical addresses have an architectural limit of 52 bits. Bits 52-62 of a PTE are reserved (must be zero), and bit 63 is the NX bit.
Quoted 8 lines
The documentation I'm using:
"Intel 64 and IA-32 Architectures Software Development Manual,
Volume 3A: System Programming Guide, Part 1""3.8 36-Bit Physical Addressing Using The PAE Paging Mechanism"
Lists bits 36-63 as "must be zero".
This disagrees with the AMD docs, which allow full 52-bit addresses in legacy mode. This may be a historical thing.
Quoted 3 lines
"3.10 PAE-Enabled Paging in IA-32e Mode"
Lists bits 40-51 as "must be zero".
The AMD docs define a 52-bit physical address space. I'm not sure what the behavior is on CPUs that only implement a smaller physical address bus.
Quoted 1 line
Lists bits 52 to 62 as "available".
The AMD docs, and some versions of the Intel docs list these as must be zero. This may be annother case of Intel screwing up the architecture. I wouldn't be surprised if future CPUs define these bits to have some meaning.
Paul
Quoted 4 lines · Stuart Brady
The documentation I'm using:
"Intel 64 and IA-32 Architectures Software Development Manual,
Volume 3A: System Programming Guide, Part 1"
...
"AMD64 Architecture Programmer's Manual, Volume 2: System Programming" gives a different story.
Only bits 52-63 are reserved (MBZ), although for PDEs and PTEs (but not PDPEs, it would seem), bit 63 is the NX bit.
However, "The AMD x86-64 Architecture Programmers Overview" says that "bits 63:52 in all page-table entry formats are available for use by system software".
Signature · 1 line
Stuart Brady