Introduction of support for the 64-bit SPARC V9 architecture. This

version supports running against a live kernel.  Compressed kdump
support is also here, but the crash dump support for the kernel,
kexec-tools, and makedumpfile is still pending.  Initial work was
done by Karl Volz with help from Bob Picco.
(dave.kleikamp@oracle.com)
This commit is contained in:
Dave Anderson 2016-04-26 14:45:59 -04:00
parent 569002249b
commit fd2f8ef41e
8 changed files with 1516 additions and 8 deletions

View File

@ -20,7 +20,7 @@
PROGRAM=crash
#
# Supported targets: X86 ALPHA PPC IA64 PPC64
# Supported targets: X86 ALPHA PPC IA64 PPC64 SPARC64
# TARGET and GDB_CONF_FLAGS will be configured automatically by configure
#
TARGET=
@ -62,7 +62,7 @@ VMWARE_HFILES=vmware_vmss.h
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 \
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 \
arm.c arm64.c mips.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 \
@ -81,7 +81,7 @@ SOURCE_FILES=${CFILES} ${GENERIC_HFILES} ${MCORE_HFILES} \
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 \
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 \
arm.o arm64.o mips.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 \
@ -422,6 +422,9 @@ arm64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} arm64.c
mips.o: ${GENERIC_HFILES} ${REDHAT_HFILES} mips.c
${CC} -c ${CRASH_CFLAGS} mips.c ${WARNING_OPTIONS} ${WARNING_ERROR}
sparc64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} sparc64.c
${CC} -c ${CRASH_CFLAGS} sparc64.c ${WARNING_OPTIONS} ${WARNING_ERROR}
s390.o: ${GENERIC_HFILES} ${IBM_HFILES} s390.c
${CC} -c ${CRASH_CFLAGS} s390.c ${WARNING_OPTIONS} ${WARNING_ERROR}

View File

@ -104,6 +104,7 @@ void add_extra_lib(char *);
#undef X86_64
#undef ARM
#undef ARM64
#undef SPARC64
#define UNKNOWN 0
#define X86 1
@ -117,6 +118,7 @@ void add_extra_lib(char *);
#define ARM 9
#define ARM64 10
#define MIPS 11
#define SPARC64 12
#define TARGET_X86 "TARGET=X86"
#define TARGET_ALPHA "TARGET=ALPHA"
@ -129,6 +131,7 @@ void add_extra_lib(char *);
#define TARGET_ARM "TARGET=ARM"
#define TARGET_ARM64 "TARGET=ARM64"
#define TARGET_MIPS "TARGET=MIPS"
#define TARGET_SPARC64 "TARGET=SPARC64"
#define TARGET_CFLAGS_X86 "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
#define TARGET_CFLAGS_ALPHA "TARGET_CFLAGS="
@ -149,6 +152,7 @@ void add_extra_lib(char *);
#define TARGET_CFLAGS_MIPS "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
#define TARGET_CFLAGS_MIPS_ON_X86 "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
#define TARGET_CFLAGS_MIPS_ON_X86_64 "TARGET_CFLAGS=-m32 -D_FILE_OFFSET_BITS=64"
#define TARGET_CFLAGS_SPARC64 "TARGET_CFLAGS="
#define GDB_TARGET_DEFAULT "GDB_CONF_FLAGS="
#define GDB_TARGET_ARM_ON_X86 "GDB_CONF_FLAGS=--target=arm-elf-linux"
@ -378,6 +382,9 @@ get_current_configuration(struct supported_gdb_version *sp)
#ifdef __mips__
target_data.target = MIPS;
#endif
#ifdef __sparc_v9__
target_data.target = SPARC64;
#endif
set_initial_target(sp);
@ -510,6 +517,10 @@ get_current_configuration(struct supported_gdb_version *sp)
if ((target_data.target == PPC) &&
(target_data.initial_gdb_target != PPC))
arch_mismatch(sp);
if ((target_data.target == SPARC64) &&
(target_data.initial_gdb_target != SPARC64))
arch_mismatch(sp);
}
if ((fp = fopen("Makefile", "r")) == NULL) {
@ -620,6 +631,9 @@ show_configuration(void)
case MIPS:
printf("TARGET: MIPS\n");
break;
case SPARC64:
printf("TARGET: SPARC64\n");
break;
}
if (strlen(target_data.program)) {
@ -729,6 +743,10 @@ build_configure(struct supported_gdb_version *sp)
} else
target_CFLAGS = TARGET_CFLAGS_MIPS;
break;
case SPARC64:
target = TARGET_SPARC64;
target_CFLAGS = TARGET_CFLAGS_SPARC64;
break;
}
ldflags = get_extra_flags("LDFLAGS.extra", NULL);
@ -1325,7 +1343,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\n");
printf("ExclusiveArch: %%{ix86} alpha ia64 ppc ppc64 ppc64pseries ppc64iseries x86_64 s390 s390x arm aarch64 ppc64le mips mipsel sparc64\n");
printf("Buildroot: %%{_tmppath}/%%{name}-root\n");
printf("BuildRequires: ncurses-devel zlib-devel bison\n");
printf("Requires: binutils\n");
@ -1554,6 +1572,8 @@ set_initial_target(struct supported_gdb_version *sp)
target_data.initial_gdb_target = ARM;
else if (strncmp(buf, "MIPS", strlen("MIPS")) == 0)
target_data.initial_gdb_target = MIPS;
else if (strncmp(buf, "SPARC64", strlen("SPARC64")) == 0)
target_data.initial_gdb_target = SPARC64;
}
char *
@ -1572,6 +1592,7 @@ target_to_name(int target)
case ARM: return("ARM");
case ARM64: return("ARM64");
case MIPS: return("MIPS");
case SPARC64: return("SPARC64");
}
return "UNKNOWN";
@ -1630,6 +1651,8 @@ name_to_target(char *name)
return MIPS;
else if (strncmp(name, "MIPS", strlen("MIPS")) == 0)
return MIPS;
else if (strncmp(name, "sparc64", strlen("sparc64")) == 0)
return SPARC64;
return UNKNOWN;
}

179
defs.h
View File

@ -71,7 +71,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(ARM) && !defined(ARM64) && !defined(MIPS) && !defined(SPARC64)
#ifdef __alpha__
#define ALPHA
#endif
@ -106,6 +106,9 @@
#ifdef __mipsel__
#define MIPS
#endif
#ifdef __sparc_v9__
#define SPARC64
#endif
#endif
#ifdef X86
@ -141,6 +144,14 @@
#ifdef MIPS
#define NR_CPUS (32)
#endif
#ifdef SPARC64
#define NR_CPUS (4096)
#endif
/* Some architectures require memory accesses to be aligned. */
#if defined(SPARC64)
#define NEED_ALIGNED_MEM_ACCESS
#endif
#define BUFSIZE (1500)
#define NULLCHAR ('\0')
@ -2187,6 +2198,45 @@ struct builtin_debug_table {
* Facilitators for pulling correctly-sized data out of a buffer at a
* known address.
*/
#ifdef NEED_ALIGNED_MEM_ACCESS
#define DEF_LOADER(TYPE) \
static inline TYPE \
load_##TYPE (char *addr) \
{ \
TYPE ret; \
size_t i = sizeof(TYPE); \
while (i--) \
((char *)&ret)[i] = addr[i]; \
return ret; \
}
DEF_LOADER(int);
DEF_LOADER(uint);
DEF_LOADER(long);
DEF_LOADER(ulong);
DEF_LOADER(ulonglong);
DEF_LOADER(ushort);
DEF_LOADER(short);
typedef void *pointer_t;
DEF_LOADER(pointer_t);
#define LOADER(TYPE) load_##TYPE
#define INT(ADDR) LOADER(int) ((char *)(ADDR))
#define UINT(ADDR) LOADER(uint) ((char *)(ADDR))
#define LONG(ADDR) LOADER(long) ((char *)(ADDR))
#define ULONG(ADDR) LOADER(ulong) ((char *)(ADDR))
#define ULONGLONG(ADDR) LOADER(ulonglong) ((char *)(ADDR))
#define ULONG_PTR(ADDR) ((ulong *) (LOADER(pointer_t) ((char *)(ADDR))))
#define USHORT(ADDR) LOADER(ushort) ((char *)(ADDR))
#define SHORT(ADDR) LOADER(short) ((char *)(ADDR))
#define UCHAR(ADDR) *((unsigned char *)((char *)(ADDR)))
#define VOID_PTR(ADDR) ((void *) (LOADER(pointer_t) ((char *)(ADDR))))
#else
#define INT(ADDR) *((int *)((char *)(ADDR)))
#define UINT(ADDR) *((uint *)((char *)(ADDR)))
#define LONG(ADDR) *((long *)((char *)(ADDR)))
@ -2198,6 +2248,8 @@ struct builtin_debug_table {
#define UCHAR(ADDR) *((unsigned char *)((char *)(ADDR)))
#define VOID_PTR(ADDR) *((void **)((char *)(ADDR)))
#endif /* NEED_ALIGNED_MEM_ACCESS */
struct node_table {
int node_id;
ulong pgdat;
@ -3816,6 +3868,110 @@ struct efi_memory_desc_t {
#endif /* S390X */
#ifdef SPARC64
#define _64BIT_
#define MACHINE_TYPE "SPARC64"
#define PTOV(X) \
((unsigned long)(X) + machdep->machspec->page_offset)
#define VTOP(X) \
((unsigned long)(X) - machdep->machspec->page_offset)
#define PAGE_OFFSET (machdep->machspec->page_offset)
extern int sparc64_IS_VMALLOC_ADDR(ulong vaddr);
#define IS_VMALLOC_ADDR(X) sparc64_IS_VMALLOC_ADDR((ulong)(X))
#define PAGE_SHIFT (13)
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE - 1))
#define PAGEBASE(X) (((ulong)(X)) & (ulong)machdep->pagemask)
#define THREAD_SIZE (2 * PAGE_SIZE)
/* S3 Core
* Core 48-bit physical address supported.
* Bit 47 distinguishes memory or I/O. When set to "1" it is I/O.
*/
#define PHYS_MASK_SHIFT (47)
#define PHYS_MASK (((1UL) << PHYS_MASK_SHIFT) - 1)
typedef signed int s32;
/*
* This next two defines are convenience defines for normal page table.
*/
#define PTES_PER_PAGE (1UL << (PAGE_SHIFT - 3))
#define PTES_PER_PAGE_MASK (PTES_PER_PAGE - 1)
/* 4-level page table */
#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3))
#define PMD_SIZE (1UL << PMD_SHIFT)
#define PMD_MASK (~(PMD_SIZE - 1))
#define PMD_BITS (PAGE_SHIFT - 3)
#define PUD_SHIFT (PMD_SHIFT + PMD_BITS)
#define PUD_SIZE (1UL << PUD_SHIFT)
#define PUD_MASK (~(PUD_SIZE - 1))
#define PUD_BITS (PAGE_SHIFT - 3)
#define PGDIR_SHIFT (PUD_SHIFT + PUD_BITS)
#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
#define PGDIR_MASK (~(PGDIR_SIZE - 1))
#define PGDIR_BITS (PAGE_SHIFT - 3)
#define PTRS_PER_PTE (1UL << (PAGE_SHIFT - 3))
#define PTRS_PER_PMD (1UL << PMD_BITS)
#define PTRS_PER_PUD (1UL << PUD_BITS)
#define PTRS_PER_PGD (1UL << PGDIR_BITS)
#define HPAGE_SHIFT (23)
/* Down one huge page */
#define SPARC64_USERSPACE_TOP (-(1UL << HPAGE_SHIFT))
#define PAGE_PMD_HUGE (0x0100000000000000UL)
/* These are for SUN4V. */
#define _PAGE_VALID (0x8000000000000000UL)
#define _PAGE_NFO_4V (0x4000000000000000UL)
#define _PAGE_MODIFIED_4V (0x2000000000000000UL)
#define _PAGE_ACCESSED_4V (0x1000000000000000UL)
#define _PAGE_READ_4V (0x0800000000000000UL)
#define _PAGE_WRITE_4V (0x0400000000000000UL)
#define _PAGE_PADDR_4V (0x00FFFFFFFFFFE000UL)
#define _PAGE_PFN_MASK (_PAGE_PADDR_4V)
#define _PAGE_P_4V (0x0000000000000100UL)
#define _PAGE_EXEC_4V (0x0000000000000080UL)
#define _PAGE_W_4V (0x0000000000000040UL)
#define _PAGE_PRESENT_4V (0x0000000000000010UL)
#define _PAGE_SZALL_4V (0x0000000000000007UL)
/* There are other page sizes. Some supported. */
#define _PAGE_SZ4MB_4V (0x0000000000000003UL)
#define _PAGE_SZ512K_4V (0x0000000000000002UL)
#define _PAGE_SZ64K_4V (0x0000000000000001UL)
#define _PAGE_SZ8K_4V (0x0000000000000000UL)
#define SPARC64_MODULES_VADDR (0x0000000010000000UL)
#define SPARC64_MODULES_END (0x00000000f0000000UL)
#define SPARC64_VMALLOC_START (0x0000000100000000UL)
#define SPARC64_STACK_SIZE 0x4000
/* sparsemem */
#define _SECTION_SIZE_BITS 30
#define _MAX_PHYSMEM_BITS 53
#define STACK_BIAS 2047
struct machine_specific {
ulong page_offset;
ulong vmalloc_end;
};
#define TIF_SIGPENDING (2)
#define SWP_OFFSET(E) ((E) >> (PAGE_SHIFT + 8UL))
#define SWP_TYPE(E) (((E) >> PAGE_SHIFT) & 0xffUL)
#define __swp_type(E) SWP_TYPE(E)
#define __swp_offset(E) SWP_OFFSET(E)
#endif /* SPARC64 */
#ifdef PLATFORM
#define SWP_TYPE(entry) (error("PLATFORM_SWP_TYPE: TBD\n"))
@ -3880,6 +4036,10 @@ struct efi_memory_desc_t {
#define MAX_HEXADDR_STRLEN (8)
#define UVADDR_PRLEN (8)
#endif
#ifdef SPARC64
#define MAX_HEXADDR_STRLEN (16)
#define UVADDR_PRLEN (16)
#endif
#define BADADDR ((ulong)(-1))
#define BADVAL ((ulong)(-1))
@ -4430,6 +4590,9 @@ void dump_build_data(void);
#ifdef MIPS
#define machdep_init(X) mips_init(X)
#endif
#ifdef SPARC64
#define machdep_init(X) sparc64_init(X)
#endif
int clean_exit(int);
int untrusted_file(FILE *, char *);
char *readmem_function_name(void);
@ -4864,6 +5027,9 @@ void display_help_screen(char *);
#ifdef MIPS
#define dump_machdep_table(X) mips_dump_machdep_table(X)
#endif
#ifdef SPARC64
#define dump_machdep_table(X) sparc64_dump_machdep_table(X)
#endif
extern char *help_pointer[];
extern char *help_alias[];
extern char *help_ascii[];
@ -5715,6 +5881,17 @@ struct machine_specific {
};
#endif /* MIPS */
/*
* sparc64.c
*/
#ifdef SPARC64
void sparc64_init(int);
void sparc64_dump_machdep_table(ulong);
int sparc64_vmalloc_addr(ulong);
#define display_idt_table() \
error(FATAL, "The -d option is not applicable to sparc64.\n")
#endif
/*
* netdump.c
*/

View File

@ -730,6 +730,8 @@ restart:
dd->machine_type = EM_S390;
else if (machine_type("ARM64"))
dd->machine_type = EM_AARCH64;
else if (machine_type("SPARC64"))
dd->machine_type = EM_SPARCV9;
else {
error(INFO, "%s: unsupported machine type: %s\n",
DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
@ -1382,6 +1384,31 @@ get_diskdump_regs_arm64(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)
{
Elf64_Nhdr *note;
int len;
if (KDUMP_CMPRS_VALID() &&
(bt->task == tt->panic_task ||
(is_task_active(bt->task) && dd->num_prstatus_notes > 1))) {
note = (Elf64_Nhdr *)dd->nt_prstatus_percpu[bt->tc->processor];
if (!note)
error(FATAL,
"cannot determine NT_PRSTATUS ELF note "
"for %s task: %lx\n",
(bt->task == tt->panic_task) ?
"panic" : "active", bt->task);
len = sizeof(Elf64_Nhdr);
len = roundup(len + note->n_namesz, 4);
bt->machdep = (void *)((char *)note + len +
MEMBER_OFFSET("elf_prstatus", "pr_reg"));
}
machdep->get_stack_frame(bt, eip, esp);
}
/*
* Send the request to the proper architecture hander.
*/
@ -1432,6 +1459,10 @@ get_diskdump_regs(struct bt_info *bt, ulong *eip, ulong *esp)
get_diskdump_regs_arm64(bt, eip, esp);
break;
case EM_SPARCV9:
get_diskdump_regs_sparc64(bt, eip, esp);
break;
default:
error(FATAL, "%s: unsupported machine type: %s\n",
DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
@ -1577,7 +1608,8 @@ dump_note_offsets(FILE *fp)
for (tot = cnt = 0; tot < size; tot += len) {
qemu = FALSE;
if (machine_type("X86_64") || machine_type("S390X") ||
machine_type("ARM64") || machine_type("PPC64")) {
machine_type("ARM64") || machine_type("PPC64") ||
machine_type("SPARC64")) {
note64 = (void *)dd->notes_buf + tot;
len = sizeof(Elf64_Nhdr);
if (STRNEQ((char *)note64 + len, "QEMU"))
@ -1684,6 +1716,8 @@ __diskdump_memory_dump(FILE *fp)
fprintf(fp, "(EM_S390)\n"); break;
case EM_AARCH64:
fprintf(fp, "(EM_AARCH64)\n"); break;
case EM_SPARCV9:
fprintf(fp, "(EM_SPARCV9)\n"); break;
default:
fprintf(fp, "(unknown)\n"); break;
}

View File

@ -36,7 +36,7 @@
#endif
#if defined(ARM) || defined(X86) || defined(PPC) || defined(S390) || \
defined(S390X) || defined(ARM64) || defined(MIPS)
defined(S390X) || defined(ARM64) || defined(MIPS) || defined(SPARC64)
/*
* Kernel header file for Linux crash dumps.

1253
sparc64.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3398,6 +3398,11 @@ is_kernel(char *file)
goto bailout;
break;
case EM_SPARCV9:
if (machine_type_mismatch(file, "SPARC64", NULL, 0))
goto bailout;
break;
default:
if (machine_type_mismatch(file, "(unknown)", NULL, 0))
goto bailout;
@ -3669,6 +3674,11 @@ is_shared_object(char *file)
if (machine_type("ARM64"))
return TRUE;
break;
case EM_SPARCV9:
if (machine_type("SPARC64"))
return TRUE;
break;
}
if (CRASHDEBUG(1))

10
task.c
View File

@ -2369,7 +2369,10 @@ store_context(struct task_context *tc, ulong task, char *tp)
tc->pid = (ulong)(*pid_addr);
strlcpy(tc->comm, comm_addr, TASK_COMM_LEN);
tc->processor = *processor_addr;
if (machine_type("SPARC64"))
tc->processor = *(unsigned short *)processor_addr;
else
tc->processor = *processor_addr;
tc->ptask = *parent_addr;
tc->mm_struct = *mm_addr;
tc->task = task;
@ -7287,6 +7290,11 @@ get_idle_threads(ulong *tasklist, int nr_cpus)
VALID_MEMBER(runqueue_idle)) {
runqbuf = GETBUF(SIZE(runqueue));
for (i = 0; i < nr_cpus; i++) {
if (machine_type("SPARC64") &&
cpu_map_addr("possible") &&
!(in_cpu_map(POSSIBLE, i)))
continue;
if ((kt->flags & SMP) && (kt->flags & PER_CPU_OFF))
runq = rq_sp->value + kt->__per_cpu_offset[i];
else