diff options
author | Petr Tesarik <ptesarik@suse.cz> | 2012-10-31 17:45:49 +0900 |
---|---|---|
committer | Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp> | 2012-11-16 11:06:49 +0900 |
commit | 4e11405b51f5dbab65f81245145b080493623821 (patch) | |
tree | eeccde49d79ade2bbb9af60eec1c641a19c6d9e4 /arch/x86_64.c | |
parent | 6f0e83150a9c37ba31a8dacc4ea3e62aefbe42e6 (diff) |
[PATCH v3 3/9] Read the Xen crash ELF note into memory at startup.
Instead of seeking individual fields inside the ELF note, copy the
corresponding struct type from the Xen sources, so people can understand
why the code does what it does.
This is mainly a cleanup patch to improve maintainability, but it also
simplifies reusing the crash note data from other places.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Diffstat (limited to 'arch/x86_64.c')
-rw-r--r-- | arch/x86_64.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/x86_64.c b/arch/x86_64.c index d1302cc..7718d5f 100644 --- a/arch/x86_64.c +++ b/arch/x86_64.c @@ -30,6 +30,18 @@ is_vmalloc_addr(ulong vaddr) || (vaddr >= MODULES_VADDR && vaddr <= MODULES_END)); } +static unsigned long +get_xen_p2m_mfn(void) +{ + if (info->xen_crash_info_v >= 2) + return info->xen_crash_info.v2-> + dom0_pfn_to_mfn_frame_list_list; + if (info->xen_crash_info_v >= 1) + return info->xen_crash_info.v1-> + dom0_pfn_to_mfn_frame_list_list; + return NOT_FOUND_LONG_VALUE; +} + int get_phys_base_x86_64(void) { @@ -59,6 +71,7 @@ get_phys_base_x86_64(void) int get_machdep_info_x86_64(void) { + unsigned long p2m_mfn; int i, j, mfns[MAX_X86_64_FRAMES]; unsigned long frame_mfn[MAX_X86_64_FRAMES]; unsigned long buf[MFNS_PER_FRAME]; @@ -72,9 +85,14 @@ get_machdep_info_x86_64(void) * Get the information for translating domain-0's physical * address into machine address. */ - if (!readmem(MADDR_XEN, pfn_to_paddr(get_xen_p2m_mfn()), - &frame_mfn, PAGESIZE())) { - ERRMSG("Can't get p2m_mfn.\n"); + p2m_mfn = get_xen_p2m_mfn(); + if (p2m_mfn == (unsigned long)NOT_FOUND_LONG_VALUE) { + ERRMSG("Can't get p2m_mfn address.\n"); + return FALSE; + } + if (!readmem(MADDR_XEN, pfn_to_paddr(p2m_mfn), + &frame_mfn, PAGESIZE())) { + ERRMSG("Can't read p2m_mfn.\n"); return FALSE; } |