x86_64: Make mm_layouts static

The "static" keyword was omitted by mistake. This variable is not needed
outside of x86_64.c.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Add basic support of ia32

Initialize the provisionary virtual memory layout, so that uname
information can be read during open (if available).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
ia32: store CPU registers from ELF notes

Copy ia32 registers from PRSTATUS notes, if found.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Implement vtop for ia32 (PAE)

Add the code to walk ia32 PAE pagetables. The algorithm is not very
well optimized, as it always emulates hardware translation (even for
direct mapping).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Implement vtop for ia32 (non-PAE)

Add code to walk ia32 non-PAE pagetables. Same restrictions as with PAE.

Note the detection of PAE. Top of virtual memory is always mapped
(it contains fixmaps), so entry 3 in PGD must always be initialised
in PAE mode. But if the top-level table is in fact non-PAE, then the
same area corresponds to slots 6 and 7 of the PGD, which maps virtual
address range 0x1800000-0x1ffffff. These addresses are never mapped
in swapper_pg_dir, so they are left uninitialized (zero).

In other words, if bytes at offset 24 to 31 from swapper_pg_dir are
all zero, it must be a non-PAE page directory, and if they are non-zero,
it must be a PAE page directory.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Use VMCOREINFO to detect ia32 PAE

This method should be faster, but it is insufficient: If the CONFIG
row is found, then the kernel must have used PAE, but if it is not
found, it could either be a non-PAE kernel, or VMCOREINFO is missing.

Since most 32-bit kernel dumps are PAE, let's do this optimisation
anyway.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
ia32: cleanup use of constants

Except for the top-level page in PAE mode, all tables occupy exactly
one page, so the PTRS_PER_PAGE_NONPAE or PTRS_PER_PAGE_PAE constants
can be used in most places.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
ia32: follow hardware specs more closely in vtop

A few corrections:

 1. The theoretical architectural limit for physical addresses is
    in fact 52 bits.
 2. 4M pages (non-PAE huge pages) can specify up to 40 bits of physical
    address (bits 39:32 of the address are relocated to bits 20:13 of
    the page directory entry).
 3. 2M pages (PAE huge pages) must mask bits 20:12 from the PDE. Bits
    20:13 are reserved and must be zero, but bit 12 is used for PAT,
    so huge page translation is broken without this commit.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
x86_64: fix vtop translation of huge pages

Same mistake as for ia32: low bits of PSE directory entries must be
masked off.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>