Skip to content

Commit fd2f8ef

Browse files
author
Dave Anderson
committed
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. ([email protected])
1 parent 5690022 commit fd2f8ef

8 files changed

+1516
-8
lines changed

Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
PROGRAM=crash
2121

2222
#
23-
# Supported targets: X86 ALPHA PPC IA64 PPC64
23+
# Supported targets: X86 ALPHA PPC IA64 PPC64 SPARC64
2424
# TARGET and GDB_CONF_FLAGS will be configured automatically by configure
2525
#
2626
TARGET=
@@ -62,7 +62,7 @@ VMWARE_HFILES=vmware_vmss.h
6262
CFILES=main.c tools.c global_data.c memory.c filesys.c help.c task.c \
6363
kernel.c test.c gdb_interface.c configure.c net.c dev.c \
6464
alpha.c x86.c ppc.c ia64.c s390.c s390x.c s390dbf.c ppc64.c x86_64.c \
65-
arm.c arm64.c mips.c \
65+
arm.c arm64.c mips.c sparc64.c \
6666
extensions.c remote.c va_server.c va_server_v1.c symbols.c cmdline.c \
6767
lkcd_common.c lkcd_v1.c lkcd_v2_v3.c lkcd_v5.c lkcd_v7.c lkcd_v8.c\
6868
lkcd_fix_mem.c s390_dump.c lkcd_x86_trace.c \
@@ -81,7 +81,7 @@ SOURCE_FILES=${CFILES} ${GENERIC_HFILES} ${MCORE_HFILES} \
8181
OBJECT_FILES=main.o tools.o global_data.o memory.o filesys.o help.o task.o \
8282
build_data.o kernel.o test.o gdb_interface.o net.o dev.o \
8383
alpha.o x86.o ppc.o ia64.o s390.o s390x.o s390dbf.o ppc64.o x86_64.o \
84-
arm.o arm64.o mips.o \
84+
arm.o arm64.o mips.o sparc64.o \
8585
extensions.o remote.o va_server.o va_server_v1.o symbols.o cmdline.o \
8686
lkcd_common.o lkcd_v1.o lkcd_v2_v3.o lkcd_v5.o lkcd_v7.o lkcd_v8.o \
8787
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
422422
mips.o: ${GENERIC_HFILES} ${REDHAT_HFILES} mips.c
423423
${CC} -c ${CRASH_CFLAGS} mips.c ${WARNING_OPTIONS} ${WARNING_ERROR}
424424

425+
sparc64.o: ${GENERIC_HFILES} ${REDHAT_HFILES} sparc64.c
426+
${CC} -c ${CRASH_CFLAGS} sparc64.c ${WARNING_OPTIONS} ${WARNING_ERROR}
427+
425428
s390.o: ${GENERIC_HFILES} ${IBM_HFILES} s390.c
426429
${CC} -c ${CRASH_CFLAGS} s390.c ${WARNING_OPTIONS} ${WARNING_ERROR}
427430

configure.c

+24-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ void add_extra_lib(char *);
104104
#undef X86_64
105105
#undef ARM
106106
#undef ARM64
107+
#undef SPARC64
107108

108109
#define UNKNOWN 0
109110
#define X86 1
@@ -117,6 +118,7 @@ void add_extra_lib(char *);
117118
#define ARM 9
118119
#define ARM64 10
119120
#define MIPS 11
121+
#define SPARC64 12
120122

121123
#define TARGET_X86 "TARGET=X86"
122124
#define TARGET_ALPHA "TARGET=ALPHA"
@@ -129,6 +131,7 @@ void add_extra_lib(char *);
129131
#define TARGET_ARM "TARGET=ARM"
130132
#define TARGET_ARM64 "TARGET=ARM64"
131133
#define TARGET_MIPS "TARGET=MIPS"
134+
#define TARGET_SPARC64 "TARGET=SPARC64"
132135

133136
#define TARGET_CFLAGS_X86 "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
134137
#define TARGET_CFLAGS_ALPHA "TARGET_CFLAGS="
@@ -149,6 +152,7 @@ void add_extra_lib(char *);
149152
#define TARGET_CFLAGS_MIPS "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
150153
#define TARGET_CFLAGS_MIPS_ON_X86 "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
151154
#define TARGET_CFLAGS_MIPS_ON_X86_64 "TARGET_CFLAGS=-m32 -D_FILE_OFFSET_BITS=64"
155+
#define TARGET_CFLAGS_SPARC64 "TARGET_CFLAGS="
152156

153157
#define GDB_TARGET_DEFAULT "GDB_CONF_FLAGS="
154158
#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)
378382
#ifdef __mips__
379383
target_data.target = MIPS;
380384
#endif
385+
#ifdef __sparc_v9__
386+
target_data.target = SPARC64;
387+
#endif
381388

382389
set_initial_target(sp);
383390

@@ -510,6 +517,10 @@ get_current_configuration(struct supported_gdb_version *sp)
510517
if ((target_data.target == PPC) &&
511518
(target_data.initial_gdb_target != PPC))
512519
arch_mismatch(sp);
520+
521+
if ((target_data.target == SPARC64) &&
522+
(target_data.initial_gdb_target != SPARC64))
523+
arch_mismatch(sp);
513524
}
514525

515526
if ((fp = fopen("Makefile", "r")) == NULL) {
@@ -620,6 +631,9 @@ show_configuration(void)
620631
case MIPS:
621632
printf("TARGET: MIPS\n");
622633
break;
634+
case SPARC64:
635+
printf("TARGET: SPARC64\n");
636+
break;
623637
}
624638

625639
if (strlen(target_data.program)) {
@@ -729,6 +743,10 @@ build_configure(struct supported_gdb_version *sp)
729743
} else
730744
target_CFLAGS = TARGET_CFLAGS_MIPS;
731745
break;
746+
case SPARC64:
747+
target = TARGET_SPARC64;
748+
target_CFLAGS = TARGET_CFLAGS_SPARC64;
749+
break;
732750
}
733751

734752
ldflags = get_extra_flags("LDFLAGS.extra", NULL);
@@ -1325,7 +1343,7 @@ make_spec_file(struct supported_gdb_version *sp)
13251343
printf("Vendor: Red Hat, Inc.\n");
13261344
printf("Packager: Dave Anderson <[email protected]>\n");
13271345
printf("ExclusiveOS: Linux\n");
1328-
printf("ExclusiveArch: %%{ix86} alpha ia64 ppc ppc64 ppc64pseries ppc64iseries x86_64 s390 s390x arm aarch64 ppc64le mips mipsel\n");
1346+
printf("ExclusiveArch: %%{ix86} alpha ia64 ppc ppc64 ppc64pseries ppc64iseries x86_64 s390 s390x arm aarch64 ppc64le mips mipsel sparc64\n");
13291347
printf("Buildroot: %%{_tmppath}/%%{name}-root\n");
13301348
printf("BuildRequires: ncurses-devel zlib-devel bison\n");
13311349
printf("Requires: binutils\n");
@@ -1554,6 +1572,8 @@ set_initial_target(struct supported_gdb_version *sp)
15541572
target_data.initial_gdb_target = ARM;
15551573
else if (strncmp(buf, "MIPS", strlen("MIPS")) == 0)
15561574
target_data.initial_gdb_target = MIPS;
1575+
else if (strncmp(buf, "SPARC64", strlen("SPARC64")) == 0)
1576+
target_data.initial_gdb_target = SPARC64;
15571577
}
15581578

15591579
char *
@@ -1572,6 +1592,7 @@ target_to_name(int target)
15721592
case ARM: return("ARM");
15731593
case ARM64: return("ARM64");
15741594
case MIPS: return("MIPS");
1595+
case SPARC64: return("SPARC64");
15751596
}
15761597

15771598
return "UNKNOWN";
@@ -1630,6 +1651,8 @@ name_to_target(char *name)
16301651
return MIPS;
16311652
else if (strncmp(name, "MIPS", strlen("MIPS")) == 0)
16321653
return MIPS;
1654+
else if (strncmp(name, "sparc64", strlen("sparc64")) == 0)
1655+
return SPARC64;
16331656

16341657
return UNKNOWN;
16351658
}

defs.h

+178-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
#if !defined(X86) && !defined(X86_64) && !defined(ALPHA) && !defined(PPC) && \
7373
!defined(IA64) && !defined(PPC64) && !defined(S390) && !defined(S390X) && \
74-
!defined(ARM) && !defined(ARM64) && !defined(MIPS)
74+
!defined(ARM) && !defined(ARM64) && !defined(MIPS) && !defined(SPARC64)
7575
#ifdef __alpha__
7676
#define ALPHA
7777
#endif
@@ -106,6 +106,9 @@
106106
#ifdef __mipsel__
107107
#define MIPS
108108
#endif
109+
#ifdef __sparc_v9__
110+
#define SPARC64
111+
#endif
109112
#endif
110113

111114
#ifdef X86
@@ -141,6 +144,14 @@
141144
#ifdef MIPS
142145
#define NR_CPUS (32)
143146
#endif
147+
#ifdef SPARC64
148+
#define NR_CPUS (4096)
149+
#endif
150+
151+
/* Some architectures require memory accesses to be aligned. */
152+
#if defined(SPARC64)
153+
#define NEED_ALIGNED_MEM_ACCESS
154+
#endif
144155

145156
#define BUFSIZE (1500)
146157
#define NULLCHAR ('\0')
@@ -2187,6 +2198,45 @@ struct builtin_debug_table {
21872198
* Facilitators for pulling correctly-sized data out of a buffer at a
21882199
* known address.
21892200
*/
2201+
2202+
#ifdef NEED_ALIGNED_MEM_ACCESS
2203+
2204+
#define DEF_LOADER(TYPE) \
2205+
static inline TYPE \
2206+
load_##TYPE (char *addr) \
2207+
{ \
2208+
TYPE ret; \
2209+
size_t i = sizeof(TYPE); \
2210+
while (i--) \
2211+
((char *)&ret)[i] = addr[i]; \
2212+
return ret; \
2213+
}
2214+
2215+
DEF_LOADER(int);
2216+
DEF_LOADER(uint);
2217+
DEF_LOADER(long);
2218+
DEF_LOADER(ulong);
2219+
DEF_LOADER(ulonglong);
2220+
DEF_LOADER(ushort);
2221+
DEF_LOADER(short);
2222+
typedef void *pointer_t;
2223+
DEF_LOADER(pointer_t);
2224+
2225+
#define LOADER(TYPE) load_##TYPE
2226+
2227+
#define INT(ADDR) LOADER(int) ((char *)(ADDR))
2228+
#define UINT(ADDR) LOADER(uint) ((char *)(ADDR))
2229+
#define LONG(ADDR) LOADER(long) ((char *)(ADDR))
2230+
#define ULONG(ADDR) LOADER(ulong) ((char *)(ADDR))
2231+
#define ULONGLONG(ADDR) LOADER(ulonglong) ((char *)(ADDR))
2232+
#define ULONG_PTR(ADDR) ((ulong *) (LOADER(pointer_t) ((char *)(ADDR))))
2233+
#define USHORT(ADDR) LOADER(ushort) ((char *)(ADDR))
2234+
#define SHORT(ADDR) LOADER(short) ((char *)(ADDR))
2235+
#define UCHAR(ADDR) *((unsigned char *)((char *)(ADDR)))
2236+
#define VOID_PTR(ADDR) ((void *) (LOADER(pointer_t) ((char *)(ADDR))))
2237+
2238+
#else
2239+
21902240
#define INT(ADDR) *((int *)((char *)(ADDR)))
21912241
#define UINT(ADDR) *((uint *)((char *)(ADDR)))
21922242
#define LONG(ADDR) *((long *)((char *)(ADDR)))
@@ -2198,6 +2248,8 @@ struct builtin_debug_table {
21982248
#define UCHAR(ADDR) *((unsigned char *)((char *)(ADDR)))
21992249
#define VOID_PTR(ADDR) *((void **)((char *)(ADDR)))
22002250

2251+
#endif /* NEED_ALIGNED_MEM_ACCESS */
2252+
22012253
struct node_table {
22022254
int node_id;
22032255
ulong pgdat;
@@ -3816,6 +3868,110 @@ struct efi_memory_desc_t {
38163868

38173869
#endif /* S390X */
38183870

3871+
#ifdef SPARC64
3872+
#define _64BIT_
3873+
#define MACHINE_TYPE "SPARC64"
3874+
3875+
#define PTOV(X) \
3876+
((unsigned long)(X) + machdep->machspec->page_offset)
3877+
#define VTOP(X) \
3878+
((unsigned long)(X) - machdep->machspec->page_offset)
3879+
3880+
#define PAGE_OFFSET (machdep->machspec->page_offset)
3881+
3882+
extern int sparc64_IS_VMALLOC_ADDR(ulong vaddr);
3883+
#define IS_VMALLOC_ADDR(X) sparc64_IS_VMALLOC_ADDR((ulong)(X))
3884+
#define PAGE_SHIFT (13)
3885+
#define PAGE_SIZE (1UL << PAGE_SHIFT)
3886+
#define PAGE_MASK (~(PAGE_SIZE - 1))
3887+
#define PAGEBASE(X) (((ulong)(X)) & (ulong)machdep->pagemask)
3888+
#define THREAD_SIZE (2 * PAGE_SIZE)
3889+
3890+
/* S3 Core
3891+
* Core 48-bit physical address supported.
3892+
* Bit 47 distinguishes memory or I/O. When set to "1" it is I/O.
3893+
*/
3894+
#define PHYS_MASK_SHIFT (47)
3895+
#define PHYS_MASK (((1UL) << PHYS_MASK_SHIFT) - 1)
3896+
3897+
typedef signed int s32;
3898+
3899+
/*
3900+
* This next two defines are convenience defines for normal page table.
3901+
*/
3902+
#define PTES_PER_PAGE (1UL << (PAGE_SHIFT - 3))
3903+
#define PTES_PER_PAGE_MASK (PTES_PER_PAGE - 1)
3904+
3905+
/* 4-level page table */
3906+
#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3))
3907+
#define PMD_SIZE (1UL << PMD_SHIFT)
3908+
#define PMD_MASK (~(PMD_SIZE - 1))
3909+
#define PMD_BITS (PAGE_SHIFT - 3)
3910+
3911+
#define PUD_SHIFT (PMD_SHIFT + PMD_BITS)
3912+
#define PUD_SIZE (1UL << PUD_SHIFT)
3913+
#define PUD_MASK (~(PUD_SIZE - 1))
3914+
#define PUD_BITS (PAGE_SHIFT - 3)
3915+
3916+
#define PGDIR_SHIFT (PUD_SHIFT + PUD_BITS)
3917+
#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
3918+
#define PGDIR_MASK (~(PGDIR_SIZE - 1))
3919+
#define PGDIR_BITS (PAGE_SHIFT - 3)
3920+
3921+
#define PTRS_PER_PTE (1UL << (PAGE_SHIFT - 3))
3922+
#define PTRS_PER_PMD (1UL << PMD_BITS)
3923+
#define PTRS_PER_PUD (1UL << PUD_BITS)
3924+
#define PTRS_PER_PGD (1UL << PGDIR_BITS)
3925+
3926+
#define HPAGE_SHIFT (23)
3927+
/* Down one huge page */
3928+
#define SPARC64_USERSPACE_TOP (-(1UL << HPAGE_SHIFT))
3929+
#define PAGE_PMD_HUGE (0x0100000000000000UL)
3930+
3931+
/* These are for SUN4V. */
3932+
#define _PAGE_VALID (0x8000000000000000UL)
3933+
#define _PAGE_NFO_4V (0x4000000000000000UL)
3934+
#define _PAGE_MODIFIED_4V (0x2000000000000000UL)
3935+
#define _PAGE_ACCESSED_4V (0x1000000000000000UL)
3936+
#define _PAGE_READ_4V (0x0800000000000000UL)
3937+
#define _PAGE_WRITE_4V (0x0400000000000000UL)
3938+
#define _PAGE_PADDR_4V (0x00FFFFFFFFFFE000UL)
3939+
#define _PAGE_PFN_MASK (_PAGE_PADDR_4V)
3940+
#define _PAGE_P_4V (0x0000000000000100UL)
3941+
#define _PAGE_EXEC_4V (0x0000000000000080UL)
3942+
#define _PAGE_W_4V (0x0000000000000040UL)
3943+
#define _PAGE_PRESENT_4V (0x0000000000000010UL)
3944+
#define _PAGE_SZALL_4V (0x0000000000000007UL)
3945+
/* There are other page sizes. Some supported. */
3946+
#define _PAGE_SZ4MB_4V (0x0000000000000003UL)
3947+
#define _PAGE_SZ512K_4V (0x0000000000000002UL)
3948+
#define _PAGE_SZ64K_4V (0x0000000000000001UL)
3949+
#define _PAGE_SZ8K_4V (0x0000000000000000UL)
3950+
3951+
#define SPARC64_MODULES_VADDR (0x0000000010000000UL)
3952+
#define SPARC64_MODULES_END (0x00000000f0000000UL)
3953+
#define SPARC64_VMALLOC_START (0x0000000100000000UL)
3954+
3955+
#define SPARC64_STACK_SIZE 0x4000
3956+
3957+
/* sparsemem */
3958+
#define _SECTION_SIZE_BITS 30
3959+
#define _MAX_PHYSMEM_BITS 53
3960+
3961+
#define STACK_BIAS 2047
3962+
3963+
struct machine_specific {
3964+
ulong page_offset;
3965+
ulong vmalloc_end;
3966+
};
3967+
3968+
#define TIF_SIGPENDING (2)
3969+
#define SWP_OFFSET(E) ((E) >> (PAGE_SHIFT + 8UL))
3970+
#define SWP_TYPE(E) (((E) >> PAGE_SHIFT) & 0xffUL)
3971+
#define __swp_type(E) SWP_TYPE(E)
3972+
#define __swp_offset(E) SWP_OFFSET(E)
3973+
#endif /* SPARC64 */
3974+
38193975
#ifdef PLATFORM
38203976

38213977
#define SWP_TYPE(entry) (error("PLATFORM_SWP_TYPE: TBD\n"))
@@ -3880,6 +4036,10 @@ struct efi_memory_desc_t {
38804036
#define MAX_HEXADDR_STRLEN (8)
38814037
#define UVADDR_PRLEN (8)
38824038
#endif
4039+
#ifdef SPARC64
4040+
#define MAX_HEXADDR_STRLEN (16)
4041+
#define UVADDR_PRLEN (16)
4042+
#endif
38834043

38844044
#define BADADDR ((ulong)(-1))
38854045
#define BADVAL ((ulong)(-1))
@@ -4430,6 +4590,9 @@ void dump_build_data(void);
44304590
#ifdef MIPS
44314591
#define machdep_init(X) mips_init(X)
44324592
#endif
4593+
#ifdef SPARC64
4594+
#define machdep_init(X) sparc64_init(X)
4595+
#endif
44334596
int clean_exit(int);
44344597
int untrusted_file(FILE *, char *);
44354598
char *readmem_function_name(void);
@@ -4864,6 +5027,9 @@ void display_help_screen(char *);
48645027
#ifdef MIPS
48655028
#define dump_machdep_table(X) mips_dump_machdep_table(X)
48665029
#endif
5030+
#ifdef SPARC64
5031+
#define dump_machdep_table(X) sparc64_dump_machdep_table(X)
5032+
#endif
48675033
extern char *help_pointer[];
48685034
extern char *help_alias[];
48695035
extern char *help_ascii[];
@@ -5715,6 +5881,17 @@ struct machine_specific {
57155881
};
57165882
#endif /* MIPS */
57175883

5884+
/*
5885+
* sparc64.c
5886+
*/
5887+
#ifdef SPARC64
5888+
void sparc64_init(int);
5889+
void sparc64_dump_machdep_table(ulong);
5890+
int sparc64_vmalloc_addr(ulong);
5891+
#define display_idt_table() \
5892+
error(FATAL, "The -d option is not applicable to sparc64.\n")
5893+
#endif
5894+
57185895
/*
57195896
* netdump.c
57205897
*/

0 commit comments

Comments
 (0)