Skip to content

Commit

Permalink
Introduction of support for the 64-bit SPARC V9 architecture. This
Browse files Browse the repository at this point in the history
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.
([email protected])
  • Loading branch information
Dave Anderson committed Apr 26, 2016
1 parent 5690022 commit fd2f8ef
Show file tree
Hide file tree
Showing 8 changed files with 1,516 additions and 8 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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}

Expand Down
25 changes: 24 additions & 1 deletion configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void add_extra_lib(char *);
#undef X86_64
#undef ARM
#undef ARM64
#undef SPARC64

#define UNKNOWN 0
#define X86 1
Expand All @@ -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"
Expand All @@ -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="
Expand All @@ -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"
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1325,7 +1343,7 @@ make_spec_file(struct supported_gdb_version *sp)
printf("Vendor: Red Hat, Inc.\n");
printf("Packager: Dave Anderson <[email protected]>\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");
Expand Down Expand Up @@ -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 *
Expand All @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down
179 changes: 178 additions & 1 deletion defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -106,6 +106,9 @@
#ifdef __mipsel__
#define MIPS
#endif
#ifdef __sparc_v9__
#define SPARC64
#endif
#endif

#ifdef X86
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)))
Expand All @@ -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;
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -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
*/
Expand Down
Loading

0 comments on commit fd2f8ef

Please sign in to comment.