mirror of https://github.com/crash-utility/crash
Add LoongArch64 framework code support
Mainly added some environment configurations, macro definitions, specific architecture structures and some function declarations supported by the LoongArch64 architecture. Co-developed-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Ming Wang <wangming01@loongson.cn>
This commit is contained in:
parent
28891d1127
commit
35a2472e7a
7
Makefile
7
Makefile
|
@ -65,7 +65,7 @@ CFILES=main.c tools.c global_data.c memory.c filesys.c help.c task.c \
|
|||
kernel.c test.c gdb_interface.c configure.c net.c dev.c bpf.c \
|
||||
printk.c \
|
||||
alpha.c x86.c ppc.c ia64.c s390.c s390x.c s390dbf.c ppc64.c x86_64.c \
|
||||
arm.c arm64.c mips.c mips64.c riscv64.c sparc64.c \
|
||||
arm.c arm64.c mips.c mips64.c riscv64.c loongarch64.c sparc64.c \
|
||||
extensions.c remote.c va_server.c va_server_v1.c symbols.c cmdline.c \
|
||||
lkcd_common.c lkcd_v1.c lkcd_v2_v3.c lkcd_v5.c lkcd_v7.c lkcd_v8.c\
|
||||
lkcd_fix_mem.c s390_dump.c lkcd_x86_trace.c \
|
||||
|
@ -85,7 +85,7 @@ OBJECT_FILES=main.o tools.o global_data.o memory.o filesys.o help.o task.o \
|
|||
build_data.o kernel.o test.o gdb_interface.o net.o dev.o bpf.o \
|
||||
printk.o \
|
||||
alpha.o x86.o ppc.o ia64.o s390.o s390x.o s390dbf.o ppc64.o x86_64.o \
|
||||
arm.o arm64.o mips.o mips64.o riscv64.o sparc64.o \
|
||||
arm.o arm64.o mips.o mips64.o riscv64.o loongarch64.o sparc64.o \
|
||||
extensions.o remote.o va_server.o va_server_v1.o symbols.o cmdline.o \
|
||||
lkcd_common.o lkcd_v1.o lkcd_v2_v3.o lkcd_v5.o lkcd_v7.o lkcd_v8.o \
|
||||
lkcd_fix_mem.o s390_dump.o netdump.o diskdump.o makedumpfile.o xendump.o \
|
||||
|
@ -445,6 +445,9 @@ riscv64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} riscv64.c
|
|||
sparc64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} sparc64.c
|
||||
${CC} -c ${CRASH_CFLAGS} sparc64.c ${WARNING_OPTIONS} ${WARNING_ERROR}
|
||||
|
||||
loongarch64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} loongarch64.c
|
||||
${CC} -c ${CRASH_CFLAGS} loongarch64.c ${WARNING_OPTIONS} ${WARNING_ERROR}
|
||||
|
||||
s390.o: ${GENERIC_HFILES} ${IBM_HFILES} s390.c
|
||||
${CC} -c ${CRASH_CFLAGS} s390.c ${WARNING_OPTIONS} ${WARNING_ERROR}
|
||||
|
||||
|
|
43
configure.c
43
configure.c
|
@ -108,6 +108,7 @@ void add_extra_lib(char *);
|
|||
#undef SPARC64
|
||||
#undef MIPS64
|
||||
#undef RISCV64
|
||||
#undef LOONGARCH64
|
||||
|
||||
#define UNKNOWN 0
|
||||
#define X86 1
|
||||
|
@ -124,6 +125,7 @@ void add_extra_lib(char *);
|
|||
#define SPARC64 12
|
||||
#define MIPS64 13
|
||||
#define RISCV64 14
|
||||
#define LOONGARCH64 15
|
||||
|
||||
#define TARGET_X86 "TARGET=X86"
|
||||
#define TARGET_ALPHA "TARGET=ALPHA"
|
||||
|
@ -139,6 +141,7 @@ void add_extra_lib(char *);
|
|||
#define TARGET_MIPS64 "TARGET=MIPS64"
|
||||
#define TARGET_SPARC64 "TARGET=SPARC64"
|
||||
#define TARGET_RISCV64 "TARGET=RISCV64"
|
||||
#define TARGET_LOONGARCH64 "TARGET=LOONGARCH64"
|
||||
|
||||
#define TARGET_CFLAGS_X86 "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
|
||||
#define TARGET_CFLAGS_ALPHA "TARGET_CFLAGS="
|
||||
|
@ -163,6 +166,8 @@ void add_extra_lib(char *);
|
|||
#define TARGET_CFLAGS_SPARC64 "TARGET_CFLAGS="
|
||||
#define TARGET_CFLAGS_RISCV64 "TARGET_CFLAGS="
|
||||
#define TARGET_CFLAGS_RISCV64_ON_X86_64 "TARGET_CFLAGS="
|
||||
#define TARGET_CFLAGS_LOONGARCH64 "TARGET_CFLAGS="
|
||||
#define TARGET_CFLAGS_LOONGARCH64_ON_X86_64 "TARGET_CFLAGS="
|
||||
|
||||
#define GDB_TARGET_DEFAULT "GDB_CONF_FLAGS="
|
||||
#define GDB_TARGET_ARM_ON_X86 "GDB_CONF_FLAGS=--target=arm-elf-linux"
|
||||
|
@ -174,6 +179,7 @@ void add_extra_lib(char *);
|
|||
#define GDB_TARGET_MIPS_ON_X86 "GDB_CONF_FLAGS=--target=mipsel-elf-linux"
|
||||
#define GDB_TARGET_MIPS_ON_X86_64 "GDB_CONF_FLAGS=--target=mipsel-elf-linux CFLAGS=-m32 CXXFLAGS=-m32"
|
||||
#define GDB_TARGET_RISCV64_ON_X86_64 "GDB_CONF_FLAGS=--target=riscv64-unknown-linux-gnu"
|
||||
#define GDB_TARGET_LOONGARCH64_ON_X86_64 "GDB_CONF_FLAGS=--target=loongarch64-unknown-linux-gnu"
|
||||
|
||||
/*
|
||||
* The original plan was to allow the use of a particular version
|
||||
|
@ -413,6 +419,9 @@ get_current_configuration(struct supported_gdb_version *sp)
|
|||
#if defined(__riscv) && (__riscv_xlen == 64)
|
||||
target_data.target = RISCV64;
|
||||
#endif
|
||||
#ifdef __loongarch64
|
||||
target_data.target = LOONGARCH64;
|
||||
#endif
|
||||
|
||||
set_initial_target(sp);
|
||||
|
||||
|
@ -472,6 +481,12 @@ get_current_configuration(struct supported_gdb_version *sp)
|
|||
* Build an RISCV64 crash binary on an X86_64 host.
|
||||
*/
|
||||
target_data.target = RISCV64;
|
||||
} else if ((target_data.target == X86_64) &&
|
||||
(name_to_target((char *)target_data.target_as_param) == LOONGARCH64)) {
|
||||
/*
|
||||
* Build an LOONGARCH64 crash binary on an X86_64 host.
|
||||
*/
|
||||
target_data.target = LOONGARCH64;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"\ntarget=%s is not supported on the %s host architecture\n\n",
|
||||
|
@ -512,6 +527,14 @@ get_current_configuration(struct supported_gdb_version *sp)
|
|||
(target_data.target != MIPS64))
|
||||
arch_mismatch(sp);
|
||||
|
||||
if ((target_data.initial_gdb_target == LOONGARCH64) &&
|
||||
(target_data.target != LOONGARCH64)) {
|
||||
if (target_data.target == X86_64)
|
||||
target_data.target = LOONGARCH64;
|
||||
else
|
||||
arch_mismatch(sp);
|
||||
}
|
||||
|
||||
if ((target_data.initial_gdb_target == RISCV64) &&
|
||||
(target_data.target != RISCV64)) {
|
||||
if (target_data.target == X86_64)
|
||||
|
@ -686,6 +709,9 @@ show_configuration(void)
|
|||
case RISCV64:
|
||||
printf("TARGET: RISCV64\n");
|
||||
break;
|
||||
case LOONGARCH64:
|
||||
printf("TARGET: LOONGARCH64\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen(target_data.program)) {
|
||||
|
@ -811,6 +837,14 @@ build_configure(struct supported_gdb_version *sp)
|
|||
} else
|
||||
target_CFLAGS = TARGET_CFLAGS_RISCV64;
|
||||
break;
|
||||
case LOONGARCH64:
|
||||
target = TARGET_LOONGARCH64;
|
||||
if (target_data.host == X86_64) {
|
||||
target_CFLAGS = TARGET_CFLAGS_LOONGARCH64_ON_X86_64;
|
||||
gdb_conf_flags = GDB_TARGET_LOONGARCH64_ON_X86_64;
|
||||
} else
|
||||
target_CFLAGS = TARGET_CFLAGS_LOONGARCH64;
|
||||
break;
|
||||
}
|
||||
|
||||
ldflags = get_extra_flags("LDFLAGS.extra", NULL);
|
||||
|
@ -1408,7 +1442,7 @@ make_spec_file(struct supported_gdb_version *sp)
|
|||
printf("Vendor: Red Hat, Inc.\n");
|
||||
printf("Packager: Dave Anderson <anderson@redhat.com>\n");
|
||||
printf("ExclusiveOS: Linux\n");
|
||||
printf("ExclusiveArch: %%{ix86} alpha ia64 ppc ppc64 ppc64pseries ppc64iseries x86_64 s390 s390x arm aarch64 ppc64le mips mipsel mips64el sparc64 riscv64\n");
|
||||
printf("ExclusiveArch: %%{ix86} alpha ia64 ppc ppc64 ppc64pseries ppc64iseries x86_64 s390 s390x arm aarch64 ppc64le mips mipsel mips64el sparc64 riscv64 loongarch64\n");
|
||||
printf("Buildroot: %%{_tmppath}/%%{name}-root\n");
|
||||
printf("BuildRequires: ncurses-devel zlib-devel bison\n");
|
||||
printf("Requires: binutils\n");
|
||||
|
@ -1649,6 +1683,8 @@ set_initial_target(struct supported_gdb_version *sp)
|
|||
target_data.initial_gdb_target = SPARC64;
|
||||
else if (strncmp(buf, "RISCV64", strlen("RISCV64")) == 0)
|
||||
target_data.initial_gdb_target = RISCV64;
|
||||
else if (strncmp(buf, "LOONGARCH64", strlen("LOONGARCH64")) == 0)
|
||||
target_data.initial_gdb_target = LOONGARCH64;
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -1670,6 +1706,7 @@ target_to_name(int target)
|
|||
case MIPS64: return("MIPS64");
|
||||
case SPARC64: return("SPARC64");
|
||||
case RISCV64: return("RISCV64");
|
||||
case LOONGARCH64: return("LOONGARCH64");
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
|
@ -1738,6 +1775,10 @@ name_to_target(char *name)
|
|||
return RISCV64;
|
||||
else if (strncmp(name, "riscv64", strlen("riscv64")) == 0)
|
||||
return RISCV64;
|
||||
else if (strncmp(name, "loongarch64", strlen("loongarch64")) == 0)
|
||||
return LOONGARCH64;
|
||||
else if (strncmp(name, "LOONGARCH64", strlen("LOONGARCH64")) == 0)
|
||||
return LOONGARCH64;
|
||||
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
|
162
defs.h
162
defs.h
|
@ -76,7 +76,7 @@
|
|||
#if !defined(X86) && !defined(X86_64) && !defined(ALPHA) && !defined(PPC) && \
|
||||
!defined(IA64) && !defined(PPC64) && !defined(S390) && !defined(S390X) && \
|
||||
!defined(ARM) && !defined(ARM64) && !defined(MIPS) && !defined(MIPS64) && \
|
||||
!defined(RISCV64) && !defined(SPARC64)
|
||||
!defined(RISCV64) && !defined(LOONGARCH64) && !defined(SPARC64)
|
||||
#ifdef __alpha__
|
||||
#define ALPHA
|
||||
#endif
|
||||
|
@ -121,6 +121,9 @@
|
|||
#if defined(__riscv) && (__riscv_xlen == 64)
|
||||
#define RISCV64
|
||||
#endif
|
||||
#ifdef __loongarch64
|
||||
#define LOONGARCH64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef X86
|
||||
|
@ -165,6 +168,9 @@
|
|||
#ifdef RISCV64
|
||||
#define NR_CPUS (256)
|
||||
#endif
|
||||
#ifdef LOONGARCH64
|
||||
#define NR_CPUS (256)
|
||||
#endif
|
||||
|
||||
#define NR_DEVICE_DUMPS (64)
|
||||
|
||||
|
@ -3723,6 +3729,48 @@ typedef signed int s32;
|
|||
|
||||
#endif /* RISCV64 */
|
||||
|
||||
/* fix compilation errors due to elf.h version. */
|
||||
#ifndef EM_LOONGARCH
|
||||
#define EM_LOONGARCH 258
|
||||
#endif
|
||||
|
||||
#ifdef LOONGARCH64
|
||||
#define _64BIT_
|
||||
#define MACHINE_TYPE "LOONGARCH64"
|
||||
|
||||
#define PAGEBASE(X) (((ulong)(X)) & (ulong)machdep->pagemask)
|
||||
|
||||
#define IS_XKPRANGE(X) (((X) >= 0x8000000000000000lu) && \
|
||||
((X) < 0xc000000000000000lu))
|
||||
|
||||
#define PTOV(X) ((ulong)(X) + 0x9000000000000000lu)
|
||||
#define VTOP(X) ((ulong)(X) & 0x0000fffffffffffflu)
|
||||
|
||||
#define IS_VMALLOC_ADDR(X) (vt->vmalloc_start && (ulong)(X) >= vt->vmalloc_start)
|
||||
|
||||
#define DEFAULT_MODULES_VADDR 0xffff800000000000lu
|
||||
#define MODULES_VADDR (machdep->machspec->modules_vaddr)
|
||||
#define MODULES_END (machdep->machspec->modules_end)
|
||||
#define VMALLOC_START (machdep->machspec->vmalloc_start_addr)
|
||||
#define VMALLOC_END (machdep->machspec->vmalloc_end)
|
||||
|
||||
#define __SWP_TYPE_SHIFT 16
|
||||
#define __SWP_TYPE_BITS 8
|
||||
#define __SWP_TYPE_MASK ((1 << __SWP_TYPE_BITS) - 1)
|
||||
#define __SWP_OFFSET_SHIFT (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT)
|
||||
|
||||
#define SWP_TYPE(entry) (((entry) >> __SWP_TYPE_SHIFT) & __SWP_TYPE_MASK)
|
||||
#define SWP_OFFSET(entry) ((entry) >> __SWP_OFFSET_SHIFT)
|
||||
|
||||
#define __swp_type(entry) SWP_TYPE(entry)
|
||||
#define __swp_offset(entry) SWP_OFFSET(entry)
|
||||
|
||||
#define TIF_SIGPENDING (1)
|
||||
|
||||
#define _SECTION_SIZE_BITS 28
|
||||
#define _MAX_PHYSMEM_BITS 48
|
||||
#endif /* LOONGARCH64 */
|
||||
|
||||
#ifdef X86
|
||||
#define _32BIT_
|
||||
#define MACHINE_TYPE "X86"
|
||||
|
@ -4775,6 +4823,10 @@ struct machine_specific {
|
|||
#define MAX_HEXADDR_STRLEN (16)
|
||||
#define UVADDR_PRLEN (16)
|
||||
#endif
|
||||
#ifdef LOONGARCH64
|
||||
#define MAX_HEXADDR_STRLEN (16)
|
||||
#define UVADDR_PRLEN (16)
|
||||
#endif
|
||||
|
||||
#define BADADDR ((ulong)(-1))
|
||||
#define BADVAL ((ulong)(-1))
|
||||
|
@ -5396,6 +5448,9 @@ void dump_build_data(void);
|
|||
#ifdef SPARC64
|
||||
#define machdep_init(X) sparc64_init(X)
|
||||
#endif
|
||||
#ifdef LOONGARCH64
|
||||
#define machdep_init(X) loongarch64_init(X)
|
||||
#endif
|
||||
int clean_exit(int);
|
||||
int untrusted_file(FILE *, char *);
|
||||
char *readmem_function_name(void);
|
||||
|
@ -5887,6 +5942,10 @@ void display_help_screen(char *);
|
|||
#ifdef RISCV64
|
||||
#define dump_machdep_table(X) riscv64_dump_machdep_table(X)
|
||||
#endif
|
||||
#ifdef LOONGARCH64
|
||||
#define dump_machdep_table(X) loongarch64_dump_machdep_table(X)
|
||||
#endif
|
||||
|
||||
extern char *help_pointer[];
|
||||
extern char *help_alias[];
|
||||
extern char *help_ascii[];
|
||||
|
@ -7109,6 +7168,107 @@ int sparc64_vmalloc_addr(ulong);
|
|||
error(FATAL, "The -d option is not applicable to sparc64.\n")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* loongarch64.c
|
||||
*/
|
||||
void loongarch64_display_regs_from_elf_notes(int, FILE *);
|
||||
#ifdef LOONGARCH64
|
||||
void loongarch64_init(int);
|
||||
void loongarch64_dump_machdep_table(ulong);
|
||||
|
||||
#define display_idt_table() \
|
||||
error(FATAL, "-d option is not applicable to LOONGARCH64 architecture\n")
|
||||
|
||||
|
||||
#define KSYMS_START (0x1)
|
||||
|
||||
struct machine_specific {
|
||||
ulong phys_base;
|
||||
ulong vmalloc_start_addr;
|
||||
ulong modules_vaddr;
|
||||
ulong modules_end;
|
||||
|
||||
struct loongarch64_pt_regs *crash_task_regs;
|
||||
};
|
||||
|
||||
/*
|
||||
* Basic page table format:
|
||||
*
|
||||
* 63 62 61 PALEN-1 12 10 9 8 7 6 5 4 3 2 1 0
|
||||
* +----+--+--+------+--------------------+----+--+--+-+-+-+---+---+-+-+
|
||||
* |RPLV|NX|NR| | PA[PALEN-1:12] | |SP|PN|W|P|G|MAT|PLV|D|V|
|
||||
* +----+--+--+------+--------------------+----+--+--+-+-+-+---+---+-+-+
|
||||
*
|
||||
*
|
||||
* Huge page table format:
|
||||
*
|
||||
* 63 62 61 PALEN-1 12 10 9 8 7 6 5 4 3 2 1 0
|
||||
* +----+--+--+------+-----------------+--+----+--+--+-+-+-+---+---+-+-+
|
||||
* |RPLV|NX|NR| | PA[PALEN-1:12] | G| |SP|PN|W|P|H|MAT|PLV|D|V|
|
||||
* +----+--+--+------+-----------------+--+----+--+--+-+-+-+---+---+-+-+
|
||||
*
|
||||
*/
|
||||
/* from arch/loongarch/include/asm/pgtable-bits.h */
|
||||
|
||||
/* Page table bits */
|
||||
#define _PAGE_VALID_SHIFT 0
|
||||
#define _PAGE_ACCESSED_SHIFT 0 /* Reuse Valid for Accessed */
|
||||
#define _PAGE_DIRTY_SHIFT 1
|
||||
#define _PAGE_PLV_SHIFT 2 /* 2~3, two bits */
|
||||
#define _CACHE_SHIFT 4 /* 4~5, two bits */
|
||||
#define _PAGE_GLOBAL_SHIFT 6
|
||||
#define _PAGE_HUGE_SHIFT 6 /* HUGE is a PMD bit */
|
||||
#define _PAGE_PRESENT_SHIFT 7
|
||||
#define _PAGE_WRITE_SHIFT 8
|
||||
#define _PAGE_MODIFIED_SHIFT 9
|
||||
#define _PAGE_PROTNONE_SHIFT 10
|
||||
#define _PAGE_SPECIAL_SHIFT 11
|
||||
#define _PAGE_HGLOBAL_SHIFT 12 /* HGlobal is a PMD bit */
|
||||
#define _PAGE_PFN_SHIFT 12
|
||||
#define _PAGE_SWP_EXCLUSIVE_SHIFT 23
|
||||
#define _PAGE_PFN_END_SHIFT 48
|
||||
#define _PAGE_PRESENT_INVALID_SHIFT 60
|
||||
#define _PAGE_NO_READ_SHIFT 61
|
||||
#define _PAGE_NO_EXEC_SHIFT 62
|
||||
#define _PAGE_RPLV_SHIFT 63
|
||||
|
||||
#ifndef _ULCAST_
|
||||
#define _ULCAST_ (unsigned long)
|
||||
#endif
|
||||
|
||||
/* Used by software */
|
||||
#define _PAGE_PRESENT (_ULCAST_(1) << _PAGE_PRESENT_SHIFT)
|
||||
#define _PAGE_PRESENT_INVALID (_ULCAST_(1) << _PAGE_PRESENT_INVALID_SHIFT)
|
||||
#define _PAGE_WRITE (_ULCAST_(1) << _PAGE_WRITE_SHIFT)
|
||||
#define _PAGE_ACCESSED (_ULCAST_(1) << _PAGE_ACCESSED_SHIFT)
|
||||
#define _PAGE_MODIFIED (_ULCAST_(1) << _PAGE_MODIFIED_SHIFT)
|
||||
#define _PAGE_PROTNONE (_ULCAST_(1) << _PAGE_PROTNONE_SHIFT)
|
||||
#define _PAGE_SPECIAL (_ULCAST_(1) << _PAGE_SPECIAL_SHIFT)
|
||||
|
||||
/* We borrow bit 23 to store the exclusive marker in swap PTEs. */
|
||||
#define _PAGE_SWP_EXCLUSIVE (_ULCAST_(1) << _PAGE_SWP_EXCLUSIVE_SHIFT)
|
||||
|
||||
/* Used by TLB hardware (placed in EntryLo*) */
|
||||
#define _PAGE_VALID (_ULCAST_(1) << _PAGE_VALID_SHIFT)
|
||||
#define _PAGE_DIRTY (_ULCAST_(1) << _PAGE_DIRTY_SHIFT)
|
||||
#define _PAGE_PLV (_ULCAST_(3) << _PAGE_PLV_SHIFT)
|
||||
#define _PAGE_GLOBAL (_ULCAST_(1) << _PAGE_GLOBAL_SHIFT)
|
||||
#define _PAGE_HUGE (_ULCAST_(1) << _PAGE_HUGE_SHIFT)
|
||||
#define _PAGE_HGLOBAL (_ULCAST_(1) << _PAGE_HGLOBAL_SHIFT)
|
||||
#define _PAGE_NO_READ (_ULCAST_(1) << _PAGE_NO_READ_SHIFT)
|
||||
#define _PAGE_NO_EXEC (_ULCAST_(1) << _PAGE_NO_EXEC_SHIFT)
|
||||
#define _PAGE_RPLV (_ULCAST_(1) << _PAGE_RPLV_SHIFT)
|
||||
#define _CACHE_MASK (_ULCAST_(3) << _CACHE_SHIFT)
|
||||
#define _PFN_SHIFT (PAGESHIFT() - 12 + _PAGE_PFN_SHIFT)
|
||||
|
||||
#define _PAGE_USER (PLV_USER << _PAGE_PLV_SHIFT)
|
||||
#define _PAGE_KERN (PLV_KERN << _PAGE_PLV_SHIFT)
|
||||
|
||||
#define _PFN_MASK (~((_ULCAST_(1) << (_PFN_SHIFT)) - 1) & \
|
||||
((_ULCAST_(1) << (_PAGE_PFN_END_SHIFT)) - 1))
|
||||
|
||||
#endif /* LOONGARCH64 */
|
||||
|
||||
/*
|
||||
* netdump.c
|
||||
*/
|
||||
|
|
19
diskdump.c
19
diskdump.c
|
@ -684,6 +684,9 @@ restart:
|
|||
else if (STRNEQ(header->utsname.machine, "riscv64") &&
|
||||
machine_type_mismatch(file, "RISCV64", NULL, 0))
|
||||
goto err;
|
||||
else if (STRNEQ(header->utsname.machine, "loongarch64") &&
|
||||
machine_type_mismatch(file, "LOONGARCH64", NULL, 0))
|
||||
goto err;
|
||||
|
||||
if (header->block_size != block_size) {
|
||||
block_size = header->block_size;
|
||||
|
@ -844,6 +847,8 @@ restart:
|
|||
dd->machine_type = EM_SPARCV9;
|
||||
else if (machine_type("RISCV64"))
|
||||
dd->machine_type = EM_RISCV;
|
||||
else if (machine_type("LOONGARCH64"))
|
||||
dd->machine_type = EM_LOONGARCH;
|
||||
else {
|
||||
error(INFO, "%s: unsupported machine type: %s\n",
|
||||
DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
|
||||
|
@ -1604,6 +1609,12 @@ get_diskdump_regs_riscv64(struct bt_info *bt, ulong *eip, ulong *esp)
|
|||
machdep->get_stack_frame(bt, eip, esp);
|
||||
}
|
||||
|
||||
static void
|
||||
get_diskdump_regs_loongarch64(struct bt_info *bt, ulong *eip, ulong *esp)
|
||||
{
|
||||
machdep->get_stack_frame(bt, eip, esp);
|
||||
}
|
||||
|
||||
static void
|
||||
get_diskdump_regs_sparc64(struct bt_info *bt, ulong *eip, ulong *esp)
|
||||
{
|
||||
|
@ -1687,6 +1698,10 @@ get_diskdump_regs(struct bt_info *bt, ulong *eip, ulong *esp)
|
|||
get_diskdump_regs_riscv64(bt, eip, esp);
|
||||
break;
|
||||
|
||||
case EM_LOONGARCH:
|
||||
get_diskdump_regs_loongarch64(bt, eip, esp);
|
||||
break;
|
||||
|
||||
default:
|
||||
error(FATAL, "%s: unsupported machine type: %s\n",
|
||||
DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
|
||||
|
@ -1834,7 +1849,7 @@ dump_note_offsets(FILE *fp)
|
|||
if (machine_type("X86_64") || machine_type("S390X") ||
|
||||
machine_type("ARM64") || machine_type("PPC64") ||
|
||||
machine_type("SPARC64") || machine_type("MIPS64") ||
|
||||
machine_type("RISCV64")) {
|
||||
machine_type("RISCV64") || machine_type("LOONGARCH64")) {
|
||||
note64 = (void *)dd->notes_buf + tot;
|
||||
len = sizeof(Elf64_Nhdr);
|
||||
if (STRNEQ((char *)note64 + len, "QEMU"))
|
||||
|
@ -1945,6 +1960,8 @@ __diskdump_memory_dump(FILE *fp)
|
|||
fprintf(fp, "(EM_AARCH64)\n"); break;
|
||||
case EM_SPARCV9:
|
||||
fprintf(fp, "(EM_SPARCV9)\n"); break;
|
||||
case EM_LOONGARCH:
|
||||
fprintf(fp, "(EM_LOONGARCH)\n"); break;
|
||||
default:
|
||||
fprintf(fp, "(unknown)\n"); break;
|
||||
}
|
||||
|
|
12822
gdb-10.2.patch
12822
gdb-10.2.patch
File diff suppressed because it is too large
Load Diff
|
@ -114,7 +114,7 @@ typedef struct _dump_header_s {
|
|||
struct new_utsname dh_utsname;
|
||||
|
||||
/* the dump registers */
|
||||
#if !defined(IA64) && !defined(S390) && !defined(S390X) && !defined(ARM64) && !defined(RISCV64)
|
||||
#if !defined(IA64) && !defined(S390) && !defined(S390X) && !defined(ARM64) && !defined(RISCV64) && !defined(LOONGARCH64)
|
||||
struct pt_regs dh_regs;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
|
||||
#if defined(ARM) || defined(X86) || defined(PPC) || defined(S390) || \
|
||||
defined(S390X) || defined(ARM64) || defined(MIPS) || \
|
||||
defined(MIPS64) || defined(SPARC64) || defined(RISCV64)
|
||||
defined(MIPS64) || defined(SPARC64) || defined(RISCV64) || \
|
||||
defined(LOONGARCH64)
|
||||
|
||||
/*
|
||||
* Kernel header file for Linux crash dumps.
|
||||
|
@ -84,7 +85,7 @@ typedef struct _dump_header_asm_s {
|
|||
uint32_t dha_eip;
|
||||
|
||||
/* the dump registers */
|
||||
#if !defined(S390) && !defined(S390X) && !defined(ARM64) && !defined(RISCV64)
|
||||
#if !defined(S390) && !defined(S390X) && !defined(ARM64) && !defined(RISCV64) && !defined(LOONGARCH64)
|
||||
struct pt_regs dha_regs;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/* loongarch64.c - core analysis suite
|
||||
*
|
||||
* Copyright (C) 2021 Loongson Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifdef LOONGARCH64
|
||||
|
||||
#include <elf.h>
|
||||
#include "defs.h"
|
||||
|
||||
/* from arch/loongarch/include/asm/ptrace.h */
|
||||
struct loongarch64_pt_regs {
|
||||
/* Saved main processor registers. */
|
||||
unsigned long regs[32];
|
||||
|
||||
/* Saved special registers. */
|
||||
unsigned long csr_crmd;
|
||||
unsigned long csr_prmd;
|
||||
unsigned long csr_euen;
|
||||
unsigned long csr_ecfg;
|
||||
unsigned long csr_estat;
|
||||
unsigned long csr_epc;
|
||||
unsigned long csr_badvaddr;
|
||||
unsigned long orig_a0;
|
||||
};
|
||||
|
||||
struct loongarch64_unwind_frame {
|
||||
unsigned long sp;
|
||||
unsigned long pc;
|
||||
unsigned long ra;
|
||||
};
|
||||
|
||||
void
|
||||
loongarch64_dump_machdep_table(ulong arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
loongarch64_init(int when)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
loongarch64_display_regs_from_elf_notes(int cpu, FILE *ofp)
|
||||
{
|
||||
}
|
||||
|
||||
#else /* !LOONGARCH64 */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
void
|
||||
loongarch64_display_regs_from_elf_notes(int cpu, FILE *ofp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* !LOONGARCH64 */
|
23
netdump.c
23
netdump.c
|
@ -43,6 +43,7 @@ static void get_netdump_regs_arm(struct bt_info *, ulong *, ulong *);
|
|||
static void get_netdump_regs_arm64(struct bt_info *, ulong *, ulong *);
|
||||
static void get_netdump_regs_mips(struct bt_info *, ulong *, ulong *);
|
||||
static void get_netdump_regs_riscv(struct bt_info *, ulong *, ulong *);
|
||||
static void get_netdump_regs_loongarch64(struct bt_info *, ulong *, ulong *);
|
||||
static void check_dumpfile_size(char *);
|
||||
static int proc_kcore_init_32(FILE *, int);
|
||||
static int proc_kcore_init_64(FILE *, int);
|
||||
|
@ -63,6 +64,7 @@ static char *vmcoreinfo_read_string(const char *);
|
|||
#define READ_PAGESIZE_FROM_VMCOREINFO() \
|
||||
(machine_type("IA64") || machine_type("PPC64") || machine_type("PPC") || machine_type("ARM64"))
|
||||
|
||||
|
||||
/*
|
||||
* kdump installs NT_PRSTATUS elf notes only to the cpus
|
||||
* that were online during dumping. Hence we call into
|
||||
|
@ -310,6 +312,12 @@ is_netdump(char *file, ulong source_query)
|
|||
goto bailout;
|
||||
break;
|
||||
|
||||
case EM_LOONGARCH:
|
||||
if (machine_type_mismatch(file, "LOONGARCH64", NULL,
|
||||
source_query))
|
||||
goto bailout;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (machine_type_mismatch(file, "(unknown)", NULL,
|
||||
source_query))
|
||||
|
@ -1493,6 +1501,9 @@ dump_Elf32_Ehdr(Elf32_Ehdr *elf)
|
|||
case EM_MIPS:
|
||||
netdump_print("(EM_MIPS)\n");
|
||||
break;
|
||||
case EM_LOONGARCH:
|
||||
netdump_print("(EM_LOONGARCH)\n");
|
||||
break;
|
||||
default:
|
||||
netdump_print("(unsupported)\n");
|
||||
break;
|
||||
|
@ -1655,6 +1666,9 @@ dump_Elf64_Ehdr(Elf64_Ehdr *elf)
|
|||
case EM_AARCH64:
|
||||
netdump_print("(EM_AARCH64)\n");
|
||||
break;
|
||||
case EM_LOONGARCH:
|
||||
netdump_print("(EM_LOONGARCH)\n");
|
||||
break;
|
||||
default:
|
||||
netdump_print("(unsupported)\n");
|
||||
break;
|
||||
|
@ -2685,6 +2699,9 @@ get_netdump_regs(struct bt_info *bt, ulong *eip, ulong *esp)
|
|||
case EM_RISCV:
|
||||
get_netdump_regs_riscv(bt, eip, esp);
|
||||
break;
|
||||
case EM_LOONGARCH:
|
||||
return get_netdump_regs_loongarch64(bt, eip, esp);
|
||||
break;
|
||||
|
||||
default:
|
||||
error(FATAL,
|
||||
|
@ -3978,6 +3995,12 @@ get_netdump_regs_riscv(struct bt_info *bt, ulong *eip, ulong *esp)
|
|||
machdep->get_stack_frame(bt, eip, esp);
|
||||
}
|
||||
|
||||
static void
|
||||
get_netdump_regs_loongarch64(struct bt_info *bt, ulong *eip, ulong *esp)
|
||||
{
|
||||
machdep->get_stack_frame(bt, eip, esp);
|
||||
}
|
||||
|
||||
int
|
||||
is_partial_netdump(void)
|
||||
{
|
||||
|
|
|
@ -190,6 +190,8 @@ char *ramdump_to_elf(void)
|
|||
e_machine = EM_X86_64;
|
||||
else if (machine_type("RISCV64"))
|
||||
e_machine = EM_RISCV;
|
||||
else if (machine_type("LOONGARCH64"))
|
||||
e_machine = EM_LOONGARCH;
|
||||
else
|
||||
error(FATAL, "ramdump: unsupported machine type: %s\n",
|
||||
MACHINE_TYPE);
|
||||
|
|
19
symbols.c
19
symbols.c
|
@ -2976,9 +2976,11 @@ store_module_kallsyms_v2(struct load_module *lm, int start, int curr,
|
|||
/*
|
||||
* On ARM/ARM64 we have linker mapping symbols like '$a'
|
||||
* or '$x' for ARM64, and '$d'.
|
||||
* On LoongArch we have linker mapping symbols like '.L'
|
||||
* or 'L0'.
|
||||
* Make sure that these don't end up into our symbol list.
|
||||
*/
|
||||
if ((machine_type("ARM") || machine_type("ARM64")) &&
|
||||
if ((machine_type("ARM") || machine_type("ARM64") || machine_type("LOONGARCH64")) &&
|
||||
!machdep->verify_symbol(nameptr, ec->st_value, ec->st_info))
|
||||
continue;
|
||||
|
||||
|
@ -4229,6 +4231,11 @@ is_kernel(char *file)
|
|||
goto bailout;
|
||||
break;
|
||||
|
||||
case EM_LOONGARCH:
|
||||
if (machine_type_mismatch(file, "LOONGARCH64", NULL, 0))
|
||||
goto bailout;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (machine_type_mismatch(file, "(unknown)", NULL, 0))
|
||||
goto bailout;
|
||||
|
@ -4283,6 +4290,11 @@ is_kernel(char *file)
|
|||
goto bailout;
|
||||
break;
|
||||
|
||||
case EM_LOONGARCH:
|
||||
if (machine_type_mismatch(file, "LOONGARCH64", NULL, 0))
|
||||
goto bailout;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (machine_type_mismatch(file, "(unknown)", NULL, 0))
|
||||
goto bailout;
|
||||
|
@ -4547,6 +4559,11 @@ is_shared_object(char *file)
|
|||
if (machine_type("RISCV64"))
|
||||
return TRUE;
|
||||
break;
|
||||
|
||||
case EM_LOONGARCH:
|
||||
if (machine_type("LOONGARCH64"))
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (CRASHDEBUG(1))
|
||||
|
|
Loading…
Reference in New Issue