eclair and crash: clean up architecture dependent codes and comply with Linux page_offset_base
Change-Id: Ie14ceb8bc9d816a9201dddd4020e2c21d6cfd686 Fujitsu: POSTK_DEBUG_ARCH_DEP_34
This commit is contained in:
committed by
Masamichi Takagi
parent
1526237bc6
commit
d5de68e97b
@@ -50,7 +50,6 @@ int print_kregs(char *rbp, size_t rbp_size, const struct arch_kregs *kregs)
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
uintptr_t virt_to_phys(uintptr_t va)
|
uintptr_t virt_to_phys(uintptr_t va)
|
||||||
{
|
{
|
||||||
extern uintptr_t kernel_base;
|
extern uintptr_t kernel_base;
|
||||||
@@ -65,5 +64,9 @@ uintptr_t virt_to_phys(uintptr_t va)
|
|||||||
|
|
||||||
return NOPHYS;
|
return NOPHYS;
|
||||||
} /* virt_to_phys() */
|
} /* virt_to_phys() */
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
|
int arch_setup_constants(void)
|
||||||
|
{
|
||||||
|
/* Nothing here */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -61,8 +61,4 @@ struct arch_kregs {
|
|||||||
unsigned long fp, sp, pc;
|
unsigned long fp, sp, pc;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
uintptr_t virt_to_phys(uintptr_t va);
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
#endif /* HEADER_USER_ARM64_ECLAIR_H */
|
#endif /* HEADER_USER_ARM64_ECLAIR_H */
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <arch-eclair.h>
|
#include <arch-eclair.h>
|
||||||
|
|
||||||
|
unsigned long linux_page_offset = 0xffff880000000000UL;
|
||||||
|
|
||||||
int print_kregs(char *rbp, size_t rbp_size, const struct arch_kregs *kregs)
|
int print_kregs(char *rbp, size_t rbp_size, const struct arch_kregs *kregs)
|
||||||
{
|
{
|
||||||
int i, ret, total = 0;
|
int i, ret, total = 0;
|
||||||
@@ -100,16 +102,15 @@ int print_kregs(char *rbp, size_t rbp_size, const struct arch_kregs *kregs)
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
uintptr_t virt_to_phys(uintptr_t va)
|
||||||
static uintptr_t virt_to_phys(uintptr_t va)
|
|
||||||
{
|
{
|
||||||
extern uintptr_t kernel_base;
|
extern uintptr_t kernel_base;
|
||||||
|
|
||||||
if (va >= MAP_KERNEL_START) {
|
if (va >= MAP_KERNEL_START) {
|
||||||
return va - MAP_KERNEL_START + kernel_base;
|
return va - MAP_KERNEL_START + kernel_base;
|
||||||
}
|
}
|
||||||
else if (va >= LINUX_PAGE_OFFSET) {
|
else if (va >= linux_page_offset) {
|
||||||
return va - LINUX_PAGE_OFFSET;
|
return va - linux_page_offset;
|
||||||
}
|
}
|
||||||
else if (va >= MAP_FIXED_START) {
|
else if (va >= MAP_FIXED_START) {
|
||||||
return va - MAP_FIXED_START;
|
return va - MAP_FIXED_START;
|
||||||
@@ -120,5 +121,16 @@ static uintptr_t virt_to_phys(uintptr_t va)
|
|||||||
|
|
||||||
return NOPHYS;
|
return NOPHYS;
|
||||||
} /* virt_to_phys() */
|
} /* virt_to_phys() */
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
int arch_setup_constants(void)
|
||||||
|
{
|
||||||
|
if (read_symbol_64("linux_page_offset_base",
|
||||||
|
&linux_page_offset) != 0) {
|
||||||
|
fprintf(stderr, "error: obtaining Linux page offset\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("x86 linux_page_offset: 0x%lx\n", linux_page_offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,10 @@
|
|||||||
#ifndef HEADER_USER_X86_ECLAIR_H
|
#ifndef HEADER_USER_X86_ECLAIR_H
|
||||||
#define HEADER_USER_X86_ECLAIR_H
|
#define HEADER_USER_X86_ECLAIR_H
|
||||||
|
|
||||||
#ifndef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
#define MAP_ST_START 0xffff800000000000UL
|
#define MAP_ST_START 0xffff800000000000UL
|
||||||
#define MAP_VMAP_START 0xffff850000000000UL
|
|
||||||
#define MAP_FIXED_START 0xffff860000000000UL
|
#define MAP_FIXED_START 0xffff860000000000UL
|
||||||
#define LINUX_PAGE_OFFSET 0xffff880000000000UL
|
|
||||||
#define MAP_KERNEL_START 0xFFFFFFFFFE800000UL
|
#define MAP_KERNEL_START 0xFFFFFFFFFE800000UL
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
extern unsigned long linux_page_offset;
|
||||||
|
|
||||||
/* TODO: these should be updated when McKernel changes */
|
|
||||||
#define MCKERNEL_ELF_START "0xFFFFFFFFFE801000"
|
|
||||||
#define MCKERNEL_ELF_LEN "0x0000000000100000"
|
|
||||||
|
|
||||||
|
|
||||||
#define ARCH_CLV_SPAN "x86_cpu_local_variables_span"
|
#define ARCH_CLV_SPAN "x86_cpu_local_variables_span"
|
||||||
|
|
||||||
#define ARCH "i386:x86-64"
|
#define ARCH "i386:x86-64"
|
||||||
@@ -31,8 +22,4 @@ struct arch_kregs {
|
|||||||
uintptr_t r15, rflags, rsp0;
|
uintptr_t r15, rflags, rsp0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
uintptr_t virt_to_phys(uintptr_t va);
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
#endif /* HEADER_USER_x86_ECLAIR_H */
|
#endif /* HEADER_USER_x86_ECLAIR_H */
|
||||||
|
|||||||
@@ -57,11 +57,7 @@ struct thread_info {
|
|||||||
int idle;
|
int idle;
|
||||||
uintptr_t process;
|
uintptr_t process;
|
||||||
uintptr_t clv;
|
uintptr_t clv;
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
uintptr_t arch_clv;
|
uintptr_t arch_clv;
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
uintptr_t x86_clv;
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
}; /* struct thread_info */
|
}; /* struct thread_info */
|
||||||
|
|
||||||
static struct options opt;
|
static struct options opt;
|
||||||
@@ -73,19 +69,13 @@ static dump_mem_chunks_t *mem_chunks;
|
|||||||
static int num_processors = -1;
|
static int num_processors = -1;
|
||||||
static asymbol **symtab = NULL;
|
static asymbol **symtab = NULL;
|
||||||
static ssize_t nsyms;
|
static ssize_t nsyms;
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
uintptr_t kernel_base;
|
uintptr_t kernel_base;
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
static uintptr_t kernel_base;
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
static struct thread_info *tihead = NULL;
|
static struct thread_info *tihead = NULL;
|
||||||
static struct thread_info **titailp = &tihead;
|
static struct thread_info **titailp = &tihead;
|
||||||
static struct thread_info *curr_thread = NULL;
|
static struct thread_info *curr_thread = NULL;
|
||||||
#ifndef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
static uintptr_t ihk_mc_switch_context = -1;
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
uintptr_t lookup_symbol(char *name) {
|
uintptr_t lookup_symbol(char *name)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nsyms; ++i) {
|
for (i = 0; i < nsyms; ++i) {
|
||||||
@@ -97,28 +87,8 @@ uintptr_t lookup_symbol(char *name) {
|
|||||||
return NOSYMBOL;
|
return NOSYMBOL;
|
||||||
} /* lookup_symbol() */
|
} /* lookup_symbol() */
|
||||||
|
|
||||||
#ifndef POSTK_DEBUG_ARCH_DEP_34
|
static int read_physmem(uintptr_t pa, void *buf, size_t size)
|
||||||
#define NOPHYS ((uintptr_t)-1)
|
{
|
||||||
|
|
||||||
static uintptr_t virt_to_phys(uintptr_t va) {
|
|
||||||
if (va >= MAP_KERNEL_START) {
|
|
||||||
return va - MAP_KERNEL_START + kernel_base;
|
|
||||||
}
|
|
||||||
else if (va >= LINUX_PAGE_OFFSET) {
|
|
||||||
return va - LINUX_PAGE_OFFSET;
|
|
||||||
}
|
|
||||||
else if (va >= MAP_FIXED_START) {
|
|
||||||
return va - MAP_FIXED_START;
|
|
||||||
}
|
|
||||||
else if (va >= MAP_ST_START) {
|
|
||||||
return va - MAP_ST_START;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NOPHYS;
|
|
||||||
} /* virt_to_phys() */
|
|
||||||
#endif /* !POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
static int read_physmem(uintptr_t pa, void *buf, size_t size) {
|
|
||||||
off_t off;
|
off_t off;
|
||||||
bfd_boolean ok;
|
bfd_boolean ok;
|
||||||
int i;
|
int i;
|
||||||
@@ -162,7 +132,8 @@ static int read_physmem(uintptr_t pa, void *buf, size_t size) {
|
|||||||
return 0;
|
return 0;
|
||||||
} /* read_physmem() */
|
} /* read_physmem() */
|
||||||
|
|
||||||
static int read_mem(uintptr_t va, void *buf, size_t size) {
|
int read_mem(uintptr_t va, void *buf, size_t size)
|
||||||
|
{
|
||||||
uintptr_t pa;
|
uintptr_t pa;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
@@ -197,15 +168,18 @@ static int read_mem(uintptr_t va, void *buf, size_t size) {
|
|||||||
return 0;
|
return 0;
|
||||||
} /* read_mem() */
|
} /* read_mem() */
|
||||||
|
|
||||||
static int read_64(uintptr_t va, void *buf) {
|
int read_64(uintptr_t va, void *buf)
|
||||||
|
{
|
||||||
return read_mem(va, buf, sizeof(uint64_t));
|
return read_mem(va, buf, sizeof(uint64_t));
|
||||||
} /* read_64() */
|
} /* read_64() */
|
||||||
|
|
||||||
static int read_32(uintptr_t va, void *buf) {
|
int read_32(uintptr_t va, void *buf)
|
||||||
|
{
|
||||||
return read_mem(va, buf, sizeof(uint32_t));
|
return read_mem(va, buf, sizeof(uint32_t));
|
||||||
} /* read_32() */
|
} /* read_32() */
|
||||||
|
|
||||||
static int read_symbol_64(char *name, void *buf) {
|
int read_symbol_64(char *name, void *buf)
|
||||||
|
{
|
||||||
uintptr_t va;
|
uintptr_t va;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
@@ -251,6 +225,12 @@ static int setup_constants(void) {
|
|||||||
int error;
|
int error;
|
||||||
uintptr_t va;
|
uintptr_t va;
|
||||||
|
|
||||||
|
error = arch_setup_constants();
|
||||||
|
if (error) {
|
||||||
|
fprintf(stderr, "error: setting up arch constants\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
va = lookup_symbol("debug_constants");
|
va = lookup_symbol("debug_constants");
|
||||||
if (va == NOSYMBOL) {
|
if (va == NOSYMBOL) {
|
||||||
perror("debug_constants");
|
perror("debug_constants");
|
||||||
@@ -302,17 +282,9 @@ static int setup_threads(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
error = read_symbol_64(ARCH_CLV_SPAN, &locals_span);
|
error = read_symbol_64(ARCH_CLV_SPAN, &locals_span);
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
error = read_symbol_64("x86_cpu_local_variables_span", &locals_span);
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
if (error) {
|
if (error) {
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
locals_span = sysconf(_SC_PAGESIZE);
|
locals_span = sysconf(_SC_PAGESIZE);
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
locals_span = 4096;
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
}
|
}
|
||||||
if (0) printf("locals 0x%lx span 0x%lx\n", locals, locals_span);
|
if (0) printf("locals 0x%lx span 0x%lx\n", locals, locals_span);
|
||||||
|
|
||||||
@@ -322,11 +294,6 @@ static int setup_threads(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
ihk_mc_switch_context = lookup_symbol("ihk_mc_switch_context");
|
|
||||||
if (0) printf("ihk_mc_switch_context: %lx\n", ihk_mc_switch_context);
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
for (cpu = 0; cpu < num_processors; ++cpu) {
|
for (cpu = 0; cpu < num_processors; ++cpu) {
|
||||||
uintptr_t v;
|
uintptr_t v;
|
||||||
uintptr_t head;
|
uintptr_t head;
|
||||||
@@ -396,11 +363,7 @@ static int setup_threads(void) {
|
|||||||
ti->process = thread;
|
ti->process = thread;
|
||||||
ti->idle = 0;
|
ti->idle = 0;
|
||||||
ti->clv = v;
|
ti->clv = v;
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
ti->arch_clv = locals + locals_span*cpu;
|
ti->arch_clv = locals + locals_span*cpu;
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
ti->x86_clv = locals + locals_span*cpu;
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
*titailp = ti;
|
*titailp = ti;
|
||||||
titailp = &ti->next;
|
titailp = &ti->next;
|
||||||
@@ -476,11 +439,7 @@ static int setup_threads(void) {
|
|||||||
ti->process = thread;
|
ti->process = thread;
|
||||||
ti->idle = 1;
|
ti->idle = 1;
|
||||||
ti->clv = v;
|
ti->clv = v;
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
ti->arch_clv = locals + locals_span * cpu;
|
||||||
ti->arch_clv = locals + locals_span*cpu;
|
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
ti->x86_clv = locals + locals_span*cpu;
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
*titailp = ti;
|
*titailp = ti;
|
||||||
titailp = &ti->next;
|
titailp = &ti->next;
|
||||||
@@ -534,11 +493,7 @@ static int setup_threads(void) {
|
|||||||
ti->process = current;
|
ti->process = current;
|
||||||
ti->idle = 1;
|
ti->idle = 1;
|
||||||
ti->clv = v;
|
ti->clv = v;
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
ti->arch_clv = locals + locals_span * cpu;
|
||||||
ti->arch_clv = locals + locals_span*cpu;
|
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
ti->x86_clv = locals + locals_span*cpu;
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
*titailp = ti;
|
*titailp = ti;
|
||||||
titailp = &ti->next;
|
titailp = &ti->next;
|
||||||
@@ -560,11 +515,7 @@ static int setup_symbols(char *fname) {
|
|||||||
ssize_t needs;
|
ssize_t needs;
|
||||||
bfd_boolean ok;
|
bfd_boolean ok;
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
symbfd = bfd_openr(fname, NULL);
|
symbfd = bfd_openr(fname, NULL);
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
symbfd = bfd_openr(fname, "elf64-x86-64");
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
|
|
||||||
if (!symbfd) {
|
if (!symbfd) {
|
||||||
bfd_perror("bfd_openr");
|
bfd_perror("bfd_openr");
|
||||||
@@ -611,11 +562,7 @@ static int setup_dump(char *fname) {
|
|||||||
char physmem_name[PHYSMEM_NAME_SIZE];
|
char physmem_name[PHYSMEM_NAME_SIZE];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
dumpbfd = bfd_fopen(opt.dump_path, NULL, "r", -1);
|
dumpbfd = bfd_fopen(opt.dump_path, NULL, "r", -1);
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
dumpbfd = bfd_fopen(opt.dump_path, "elf64-x86-64", "r", -1);
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
if (!dumpbfd) {
|
if (!dumpbfd) {
|
||||||
bfd_perror("bfd_fopen");
|
bfd_perror("bfd_fopen");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -765,17 +712,10 @@ static void command(const char *cmd, char *res, size_t res_size) {
|
|||||||
rbp += sprintf(rbp, "1");
|
rbp += sprintf(rbp, "1");
|
||||||
}
|
}
|
||||||
else if (!strncmp(p, "qXfer:features:read:target.xml:", 31)) {
|
else if (!strncmp(p, "qXfer:features:read:target.xml:", 31)) {
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
char *str =
|
char *str =
|
||||||
"<target version=\"1.0\">"
|
"<target version=\"1.0\">"
|
||||||
"<architecture>"ARCH"</architecture>"
|
"<architecture>"ARCH"</architecture>"
|
||||||
"</target>";
|
"</target>";
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
char *str =
|
|
||||||
"<target version=\"1.0\">"
|
|
||||||
"<architecture>i386:x86-64</architecture>"
|
|
||||||
"</target>";
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
rbp += sprintf(rbp, "l");
|
rbp += sprintf(rbp, "l");
|
||||||
if (0)
|
if (0)
|
||||||
rbp += print_hex(rbp, res_size, str);
|
rbp += print_hex(rbp, res_size, str);
|
||||||
@@ -802,21 +742,12 @@ static void command(const char *cmd, char *res, size_t res_size) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int error;
|
int error;
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
uintptr_t regs[ARCH_REGS];
|
uintptr_t regs[ARCH_REGS];
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
uintptr_t regs[21];
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
uint8_t *pu8;
|
uint8_t *pu8;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
error = read_mem(curr_thread->arch_clv+PANIC_REGS_OFFSET,
|
error = read_mem(curr_thread->arch_clv+PANIC_REGS_OFFSET,
|
||||||
®s, sizeof(regs));
|
®s, sizeof(regs));
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
error = read_mem(curr_thread->x86_clv+240,
|
|
||||||
®s, sizeof(regs));
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
if (error) {
|
if (error) {
|
||||||
perror("read_mem");
|
perror("read_mem");
|
||||||
break;
|
break;
|
||||||
@@ -863,17 +794,10 @@ static void command(const char *cmd, char *res, size_t res_size) {
|
|||||||
rbp += sprintf(rbp, "T0;tnotrun:0");
|
rbp += sprintf(rbp, "T0;tnotrun:0");
|
||||||
}
|
}
|
||||||
else if (!strncmp(p, "qXfer:memory-map:read::", 23)) {
|
else if (!strncmp(p, "qXfer:memory-map:read::", 23)) {
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
char *str =
|
char *str =
|
||||||
"<memory-map>"
|
"<memory-map>"
|
||||||
"<memory type=\"rom\" start=\""MAP_KERNEL_TEXT"\" length=\"0x27000\"/>"
|
"<memory type=\"rom\" start=\""MAP_KERNEL_TEXT"\" length=\"0x27000\"/>"
|
||||||
"</memory-map>";
|
"</memory-map>";
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
char *str =
|
|
||||||
"<memory-map>"
|
|
||||||
"<memory type=\"rom\" start=\"0xffffffff80001000\" length=\"0x27000\"/>"
|
|
||||||
"</memory-map>";
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
rbp += sprintf(rbp, "l");
|
rbp += sprintf(rbp, "l");
|
||||||
if (0)
|
if (0)
|
||||||
rbp += print_hex(rbp, res_size, str);
|
rbp += print_hex(rbp, res_size, str);
|
||||||
|
|||||||
@@ -10,13 +10,15 @@
|
|||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
uintptr_t lookup_symbol(char *name);
|
uintptr_t lookup_symbol(char *name);
|
||||||
|
int read_symbol_64(char *name, void *buf);
|
||||||
ssize_t print_bin(char *buf, size_t buf_size, void *data, size_t size);
|
ssize_t print_bin(char *buf, size_t buf_size, void *data, size_t size);
|
||||||
|
|
||||||
/* arch depend */
|
/* arch depend */
|
||||||
int print_kregs(char *rbp, size_t rbp_size, const struct arch_kregs *kregs);
|
int print_kregs(char *rbp, size_t rbp_size, const struct arch_kregs *kregs);
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
|
||||||
#define NOPHYS ((uintptr_t)-1)
|
#define NOPHYS ((uintptr_t)-1)
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
uintptr_t virt_to_phys(uintptr_t va);
|
||||||
|
|
||||||
|
int arch_setup_constants(void);
|
||||||
|
|
||||||
#endif /* HEADER_USER_COMMON_ECLAIR_H */
|
#endif /* HEADER_USER_COMMON_ECLAIR_H */
|
||||||
|
|||||||
@@ -244,11 +244,7 @@ void cmd_ldump2mcdump(void)
|
|||||||
|
|
||||||
bfd_init();
|
bfd_init();
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_34 /* use bfd_open target is NULL(automatic) */
|
|
||||||
abfd = bfd_fopen(fname, NULL, "w", -1);
|
abfd = bfd_fopen(fname, NULL, "w", -1);
|
||||||
#else /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
abfd = bfd_fopen(fname, "elf64-x86-64", "w", -1);
|
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_34 */
|
|
||||||
if (!abfd) {
|
if (!abfd) {
|
||||||
bfd_perror("bfd_fopen");
|
bfd_perror("bfd_fopen");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -82,7 +82,11 @@ static struct mck_size_table {
|
|||||||
#define MCK_SIZE_INIT(X, Y) (MCK_ASSIGN_SIZE(X) = STRUCT_SIZE(Y))
|
#define MCK_SIZE_INIT(X, Y) (MCK_ASSIGN_SIZE(X) = STRUCT_SIZE(Y))
|
||||||
|
|
||||||
#ifdef X86_64
|
#ifdef X86_64
|
||||||
#define LINUX_PAGE_OFFSET 0xffff880000000000UL
|
#define MAP_FIXED_START 0xffff860000000000UL
|
||||||
|
#define MAP_KERNEL_START 0xffffffff80000000UL
|
||||||
|
#define MAP_ST_START 0xffff800000000000UL
|
||||||
|
unsigned long LINUX_PAGE_OFFSET = -1UL;
|
||||||
|
unsigned long x86_kernel_phys_base = -1UL;
|
||||||
static inline ulong phys_to_virt(ulong phys)
|
static inline ulong phys_to_virt(ulong phys)
|
||||||
{
|
{
|
||||||
return phys + LINUX_PAGE_OFFSET;
|
return phys + LINUX_PAGE_OFFSET;
|
||||||
@@ -100,9 +104,29 @@ static inline ulong phys_to_virt(ulong phys)
|
|||||||
int mcreadmem(ulonglong addr, int memtype, void *buffer, long size,
|
int mcreadmem(ulonglong addr, int memtype, void *buffer, long size,
|
||||||
char *type, ulong error_handle)
|
char *type, ulong error_handle)
|
||||||
{
|
{
|
||||||
#ifdef ARM64
|
|
||||||
ulong phys;
|
ulong phys;
|
||||||
|
#ifdef X86_64
|
||||||
|
if (LINUX_PAGE_OFFSET != -1UL &&
|
||||||
|
x86_kernel_phys_base != -1UL) {
|
||||||
|
if (addr >= MAP_KERNEL_START &&
|
||||||
|
addr < MAP_KERNEL_START + 0x4000) {
|
||||||
|
phys = addr - MAP_KERNEL_START + x86_kernel_phys_base;
|
||||||
|
}
|
||||||
|
else if (addr >= LINUX_PAGE_OFFSET) {
|
||||||
|
phys = addr - LINUX_PAGE_OFFSET;
|
||||||
|
}
|
||||||
|
else if (addr >= MAP_FIXED_START) {
|
||||||
|
phys = addr - MAP_FIXED_START;
|
||||||
|
}
|
||||||
|
else if (addr >= MAP_ST_START) {
|
||||||
|
phys = addr - MAP_ST_START;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
kvtop(NULL, addr, &phys, 0);
|
||||||
|
}
|
||||||
|
addr = phys_to_virt(phys);
|
||||||
|
}
|
||||||
|
#elif defined ARM64
|
||||||
/*
|
/*
|
||||||
* Crash on ARM RedHat8 can't seem to access module space
|
* Crash on ARM RedHat8 can't seem to access module space
|
||||||
* virtual addresses, translate to kernel fixed map.
|
* virtual addresses, translate to kernel fixed map.
|
||||||
@@ -148,13 +172,6 @@ get_symbol_value(char *name)
|
|||||||
|
|
||||||
close_tmpfile2();
|
close_tmpfile2();
|
||||||
|
|
||||||
#ifdef X86_64
|
|
||||||
/* adjust symbols in MAP_ST_START */
|
|
||||||
if (value < 0xffff810000000000UL && value >= 0xffff800000000000UL) {
|
|
||||||
value += 0x80000000000UL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1050,7 +1067,8 @@ static void
|
|||||||
arch_init(void)
|
arch_init(void)
|
||||||
{
|
{
|
||||||
#ifdef X86_64
|
#ifdef X86_64
|
||||||
/* nothing to do */
|
LINUX_PAGE_OFFSET = get_symbol_value("linux_page_offset_base");
|
||||||
|
x86_kernel_phys_base = get_symbol_value("x86_kernel_phys_base");
|
||||||
#elif defined(ARM64)
|
#elif defined(ARM64)
|
||||||
V2PHYS_OFFSET = get_symbol_value("memstart_addr");
|
V2PHYS_OFFSET = get_symbol_value("memstart_addr");
|
||||||
|
|
||||||
@@ -1625,7 +1643,7 @@ cmd_mcinfo(void)
|
|||||||
#ifdef x86
|
#ifdef x86
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(fp, "LINUX_PAGE_OFFSET: 0x%lx\n", LINUX_PAGE_OFFSET);
|
||||||
#ifdef ARM64
|
#ifdef ARM64
|
||||||
fprintf(fp, "V2PHYS_OFFSET: 0x%lx\n", V2PHYS_OFFSET);
|
fprintf(fp, "V2PHYS_OFFSET: 0x%lx\n", V2PHYS_OFFSET);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user