summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2021-03-21 11:01:39 +0200
committerToomas Soome <tsoome@me.com>2021-03-26 17:55:40 +0200
commit49950d9c675502476d8644b1e5bb1bf0d743f53b (patch)
tree041d3bb7abcc239e5e69e6fb814bc4088be8b23f
parent373fc975de7796bc28f551ba20f2d72b529dfe48 (diff)
downloadillumos-joyent-49950d9c675502476d8644b1e5bb1bf0d743f53b.tar.gz
13666 stackalign: add SPARC support
Reviewed by: Yuri Pankov <yuripv@yuripv.dev> Reviewed by: Igor Kozhukhov <igor@dilos.org> Approved by: Robert Mustacchi <rm@fingolfin.org>
-rw-r--r--usr/src/test/os-tests/tests/stackalign/Makefile6
-rw-r--r--usr/src/test/os-tests/tests/stackalign/stack_sparc.s71
-rw-r--r--usr/src/test/os-tests/tests/stackalign/stack_sparcv9.s73
-rw-r--r--usr/src/test/os-tests/tests/stackalign/stackalign.c8
4 files changed, 148 insertions, 10 deletions
diff --git a/usr/src/test/os-tests/tests/stackalign/Makefile b/usr/src/test/os-tests/tests/stackalign/Makefile
index 4af7cb7352..50d0d2e028 100644
--- a/usr/src/test/os-tests/tests/stackalign/Makefile
+++ b/usr/src/test/os-tests/tests/stackalign/Makefile
@@ -21,6 +21,7 @@ PROGS64 = $(PROGS:%=%.64)
OBJS = $(PROGS32:%=%.o) $(PROGS64:%=%.o)
$(INTEL_BLD)OBJS += stack_i386.o stack_amd64.o
+$(SPARC_BLD)OBJS += stack_sparc.o stack_sparcv9.o
ROOTOPTDIR = $(ROOT)/opt/os-tests/tests
ROOTOPTSTACK = $(ROOTOPTDIR)/stackalign
@@ -31,6 +32,7 @@ include $(SRC)/cmd/Makefile.cmd
ASFLAGS += -P -D_ASM
CFLAGS += -D_REENTRANT
$(INTEL_BLD)LDFLAGS += -Wl,-zinitarray=get_stack_at_init
+$(SPARC_BLD)LDFLAGS += -Wl,-zinitarray=get_stack_at_init
.KEEP_STATE:
@@ -64,11 +66,11 @@ stack_$(MACH).o: stack_$(MACH).s
stack_$(MACH64).o: stack_$(MACH64).s
$(COMPILE64.s) $< -o $@
-%.64: %.64.o $(INTEL_BLD)stack_$(MACH64).o
+%.64: %.64.o stack_$(MACH64).o
$(LINK64.c) -o $@ $^ $(LDLIBS64)
$(POST_PROCESS)
-%.32: %.32.o $(INTEL_BLD)stack_$(MACH).o
+%.32: %.32.o stack_$(MACH).o
$(LINK.c) -o $@ $^ $(LDLIBS)
$(POST_PROCESS)
diff --git a/usr/src/test/os-tests/tests/stackalign/stack_sparc.s b/usr/src/test/os-tests/tests/stackalign/stack_sparc.s
new file mode 100644
index 0000000000..729c655ccc
--- /dev/null
+++ b/usr/src/test/os-tests/tests/stackalign/stack_sparc.s
@@ -0,0 +1,71 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2021 Tintri by DDN, Inc. All rights reserved.
+ * Copyright 2021 Toomas Soome <tsoome@me.com>
+ */
+
+/*
+ * Get the stack at entry and call a function with it as an argument.
+ */
+
+ .file "stack_sparc.s"
+
+#include <sys/asm_linkage.h>
+
+/*
+ * void
+ * get_stack_at_entry(test_ctx_t *ctx)
+ *
+ * ctx+0 is void (*)(uintptr_t stack, char *text),
+ * and ctx+4 is the 'text' argument.
+ *
+ * Passes the stack pointer prior to the invoking call instruction
+ * to the specified function.
+ */
+ ENTRY(get_stack_at_entry)
+ save %sp, -SA(MINFRAME), %sp
+ st %i0, [%fp + STACK_BIAS + ARGPUSHSIZE]
+ ld [%fp + STACK_BIAS + ARGPUSHSIZE], %g1
+ ld [%g1], %g1 /* func */
+ ld [%fp + STACK_BIAS + ARGPUSHSIZE], %g2
+ ld [%g2 + 4], %g2 /* text */
+ mov %g2, %o1
+ call %g1, 0
+ add %sp, STACK_BIAS, %o0
+ ret
+ restore
+ SET_SIZE(get_stack_at_entry)
+
+/*
+ * void
+ * get_stack_at_init(void)
+ *
+ * Passes the stack pointer prior to the invoking call instruction
+ * to initarray() (defined elsewhere).
+ * Tests alignment in section .init_array.
+ */
+ ENTRY(get_stack_at_init)
+ save %sp, -SA(MINFRAME), %sp
+ call initarray, 0
+ add %sp, STACK_BIAS, %o0
+ ret
+ restore
+ SET_SIZE(get_stack_at_init)
+
+/*
+ * Passes the stack pointer during init to initmain() (defined elsewhere).
+ * Tests alignment in section .init.
+ */
+ .section ".init"
+ call initmain, 0
+ add %sp, STACK_BIAS, %o0
diff --git a/usr/src/test/os-tests/tests/stackalign/stack_sparcv9.s b/usr/src/test/os-tests/tests/stackalign/stack_sparcv9.s
new file mode 100644
index 0000000000..91d71f8289
--- /dev/null
+++ b/usr/src/test/os-tests/tests/stackalign/stack_sparcv9.s
@@ -0,0 +1,73 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2021 Tintri by DDN, Inc. All rights reserved.
+ * Copyright 2021 Toomas Soome <tsoome@me.com>
+ */
+
+/*
+ * Get the stack at entry and call a function with it as an argument.
+ */
+
+ .file "stack_sparcv9.s"
+
+#include <sys/asm_linkage.h>
+
+/*
+ * void
+ * get_stack_at_entry(test_ctx_t *ctx)
+ *
+ * ctx+0 is void (*)(uintptr_t stack, char *text),
+ * and ctx+8 is the 'text' argument.
+ *
+ * Passes the stack pointer prior to the invoking call instruction
+ * to the specified function.
+ */
+ ENTRY(get_stack_at_entry)
+ .register %g2, #scratch
+ save %sp, -SA(MINFRAME), %sp
+ stx %i0, [%fp + STACK_BIAS + ARGPUSHSIZE]
+ ldx [%fp + STACK_BIAS + ARGPUSHSIZE], %g1
+ ldx [%g1], %g1 /* func */
+ ldx [%fp + STACK_BIAS + ARGPUSHSIZE], %g2
+ ldx [%g2 + 8], %g2 /* text */
+ mov %g2, %o1
+ call %g1, 2
+ add %sp, STACK_BIAS, %o0
+ ret
+ restore
+ SET_SIZE(get_stack_at_entry)
+
+/*
+ * void
+ * get_stack_at_init(void)
+ *
+ * Passes the stack pointer prior to the invoking call instruction
+ * to initarray() (defined elsewhere).
+ * Tests alignment in section .init_array.
+ */
+ ENTRY(get_stack_at_init)
+ save %sp, -SA(MINFRAME), %sp
+ call initarray, 0
+ add %sp, STACK_BIAS, %o0
+ ret
+ restore
+ SET_SIZE(get_stack_at_init)
+
+/*
+ * Passes the stack pointer during init to initmain() (defined elsewhere).
+ * Tests alignment in section .init.
+ */
+ .section ".init"
+ call initmain, 0
+ add %sp, STACK_BIAS, %o0
+
diff --git a/usr/src/test/os-tests/tests/stackalign/stackalign.c b/usr/src/test/os-tests/tests/stackalign/stackalign.c
index 73dd7e569e..9597ce0601 100644
--- a/usr/src/test/os-tests/tests/stackalign/stackalign.c
+++ b/usr/src/test/os-tests/tests/stackalign/stackalign.c
@@ -83,13 +83,6 @@ char door_arg[] = "DOOR ARG";
int
main(int argc, char *argv[])
{
-#if defined(__sparc)
- /*
- * This hasn't been implemented for SPARC, so skip.
- */
- fprintf(stderr, "No SPARC implementation of get_stack_at_entry\n");
- return (3);
-#else
door_arg_t da = {
.data_ptr = (void *)door_arg,
.data_size = sizeof (door_arg)
@@ -167,5 +160,4 @@ main(int argc, char *argv[])
(void) close(door_fd);
return (0);
-#endif
}