Clear ctx->ops if kdump_fdopen() fails

Commit ea51dfee688a041ed817dd4d1af4b75e55d2859d already states that this
is necessary, but does not add the code. :-(

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Rename ctx->ops->free to ctx->ops->cleanup

The name is confusing, because this callback should not really free
its argument, just clean up all arch-specific data (possibly freeing
some memory while doing that).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Infrastructure for virtual address regions

A virtual address region is a range of virtual addresses that can be
translated to physical addresses in a certain way. Initially, the
translation is uninitialized (KDUMP_XLAT_NONE).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Cleanup: define a (public) macro for the max value of kdump_addr_t

This constant looks somehow generally useful.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Implement generick kdump_vtop()

This method uses arch-specific vtop() only for KDUMP_XLAT_VTOP.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Use generic kdump_vtop() in read_kvpage()

Switch to the generic implementation. This is the only way to go after
the previous commit changed the semantic of the vtop callback.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
x86_64: Convert x86_64_vtop logic to a virtual address region

Use the address region. x86_64_vtop() should be extended to implement
walking CPU page tables. For now, the result is the same as if the
callback was not initialised.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Add kdump_flush_regions()

This function is an efficient way to remove all virtual region
translations. This should be done before setting a completely new
virtual address map to make sure that no previous mapping conflicts.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
x86_64: Define non-canonical addresses as KDUMP_XLAT_INVALID

Only canonical addresses can be translated.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
diskdump: adjust max_pfn to the size of bitmap if necessary

Since the PFN will be translated to an index in ddp->bitmap, the code
should make sure that max_pfn is not beyond the allocated area.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
check pfn against max_pfn in diskdup_read_page()

Add a safety check for out-of-bound reads. This prevents accesses
beyond the allocated bitmap if an invalid PFN is passed to this
function.

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