Set DIF_PHYS_BASE flag if phys_base is valid

This flag is set if phys_base has been determined. It should be
used to decide if kernel text can be accessed.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Set DIF_UTSNAME when utsname is complete

Set a flag when utsname is completely initialised. Note that it is
possible that only some fields in utsname are initialised (because
they are determined indirectly, e.g. from VMCOREINFO). In that case,
the flag should not be set, so the generic code can attempt an
alternative approach to fill in _all_ fields.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Provide a generic interface for using virtual addresses

Virtual address translation is needed to read values from the crashed
kernel, which is in turn sometimes needed to initialise fields that are
otherwise stored in the file header. This could be done by users of
the library, but that would be code duplication. Plus, it is convenient
if the library does it automatically.

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

The test is wrong. User-modifiable fields (nodename, domainname) can
be empty. On the other hand, the terminating NUL character must always
be present, and some code may rely on getting valid C strings if
uts "looks sane".

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
x86_64: write a trivial (and incomplete) vtop implementation

This implementation gives wrong results for anything beyond the kernel
text mapping (e.g. modules), but let's start easy and dirty and see
how far we get.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Try to read kernel utsname from kernel memory if not found in headers

If file headers do not include the full utsname, it may be possible
to read it from the dump data itself.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Provide a more powerful API for kdump_read

kdump_read() is modelled after the read() interface, but if it fails,
the reason is not passed back to the caller.

Provide a variant which takes a pointer to the buffer length (IN/OUT
argument), and reimplement kdump_read() on top of that "raw" interface.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Update use_kernel_utsname() to call kdump_readp()

The new interface is particularly well suited for internal calls,
cleaning up the error propagation path.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Remove DIF_PHYS_BASE check from x86_64_vtop()

Many dump files do not provide any way to determine the correct phys_base
offset, but the vast majority of them in fact uses an offset of zero.
It's probably better to return potentially incorrect data (and validate
it afterwards) than returning nothing and giving the caller no way to
get the data.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Provide a function to get the target architecture name

I did not make this an enum, because the library API would change
every time a new architecture is added.

But the list is fixed, and the name is hopefully somehow useful
without modifications...

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Fix return values of diskdump_read_page and lkcd_read_page

While success does not change (kdump_ok == 0), the error conditions
should be mapped onto kdump_status.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Push last_pfn checks further down the stack

The approach with read_page() is wrong, because it does not differentiate
between different address spaces, so it may return incorrect content
if a PFN happens to match an MFN, for example.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Initialize last_pfn to an invalid value

Without this change, if the first PFN to be read happens to be 0, the
page buffer is left uninitialised.

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