Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137629044
D13875.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D13875.id.diff
View Options
Index: head/lib/libc/mips/gen/makecontext.c
===================================================================
--- head/lib/libc/mips/gen/makecontext.c
+++ head/lib/libc/mips/gen/makecontext.c
@@ -38,6 +38,7 @@
#endif
#include <sys/param.h>
+#include <machine/abi.h>
#include <machine/regnum.h>
#include <stdarg.h>
@@ -75,13 +76,10 @@
((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
#if defined(__mips_o32) || defined(__mips_o64)
sp -= (argc >= 4 ? argc : 4); /* Make room for >=4 arguments. */
- sp = (register_t *)
- ((uintptr_t)sp & ~0x7); /* Align on double-word boundary. */
#elif defined(__mips_n32) || defined(__mips_n64)
sp -= (argc > 8 ? argc - 8 : 0); /* Make room for > 8 arguments. */
- sp = (register_t *)
- ((uintptr_t)sp & ~0xf); /* Align on quad-word boundary. */
#endif
+ sp = (register_t *)((uintptr_t)sp & ~(STACK_ALIGN - 1));
mc->mc_regs[SP] = (intptr_t)sp;
mc->mc_regs[S0] = (intptr_t)ucp;
Index: head/sys/mips/include/abi.h
===================================================================
--- head/sys/mips/include/abi.h
+++ head/sys/mips/include/abi.h
@@ -0,0 +1,95 @@
+/* $NetBSD: asm.h,v 1.29 2000/12/14 21:29:51 jeffs Exp $ */
+
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)machAsmDefs.h 8.1 (Berkeley) 6/10/93
+ * JNPR: asm.h,v 1.10 2007/08/09 11:23:32 katta
+ * $FreeBSD$
+ */
+
+/*
+ * machAsmDefs.h --
+ *
+ * Macros used when writing assembler programs.
+ *
+ * Copyright (C) 1989 Digital Equipment Corporation.
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appears in all copies.
+ * Digital Equipment Corporation makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
+ * v 1.2 89/08/15 18:28:24 rab Exp SPRITE (DECWRL)
+ */
+
+#ifndef _MACHINE_ABI_H_
+#define _MACHINE_ABI_H_
+
+#if defined(__mips_o32)
+#define SZREG 4
+#else
+#define SZREG 8
+#endif
+
+#if defined(__mips_o32) || defined(__mips_o64)
+#define STACK_ALIGN 8
+#else
+#define STACK_ALIGN 16
+#endif
+
+/*
+ * standard callframe {
+ * register_t cf_pad[N]; o32/64 (N=0), n32 (N=1) n64 (N=1)
+ * register_t cf_args[4]; arg0 - arg3 (only on o32 and o64)
+ * register_t cf_gp; global pointer (only on n32 and n64)
+ * register_t cf_sp; frame pointer
+ * register_t cf_ra; return address
+ * };
+ */
+#if defined(__mips_o32) || defined(__mips_o64)
+#define CALLFRAME_SIZ (SZREG * (4 + 2))
+#define CALLFRAME_S0 0
+#elif defined(__mips_n32) || defined(__mips_n64)
+#define CALLFRAME_SIZ (SZREG * 4)
+#define CALLFRAME_S0 (CALLFRAME_SIZ - 4 * SZREG)
+#endif
+#ifndef _KERNEL
+#define CALLFRAME_GP (CALLFRAME_SIZ - 3 * SZREG)
+#endif
+#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG)
+#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG)
+
+#endif /* !_MACHINE_ABI_H_ */
Index: head/sys/mips/include/asm.h
===================================================================
--- head/sys/mips/include/asm.h
+++ head/sys/mips/include/asm.h
@@ -58,6 +58,7 @@
#ifndef _MACHINE_ASM_H_
#define _MACHINE_ASM_H_
+#include <machine/abi.h>
#include <machine/regdef.h>
#include <machine/endian.h>
#include <machine/cdefs.h>
@@ -263,12 +264,6 @@
.asciiz str; \
.align 3
-#if defined(__mips_o32)
-#define SZREG 4
-#else
-#define SZREG 8
-#endif
-
#if defined(__mips_o32) || defined(__mips_o64)
#define ALSK 7 /* stack alignment */
#define ALMASK -7 /* stack alignment */
@@ -282,28 +277,6 @@
#define FP_L ldc1
#define FP_S sdc1
#endif
-
-/*
- * standard callframe {
- * register_t cf_pad[N]; o32/64 (N=0), n32 (N=1) n64 (N=1)
- * register_t cf_args[4]; arg0 - arg3 (only on o32 and o64)
- * register_t cf_gp; global pointer (only on n32 and n64)
- * register_t cf_sp; frame pointer
- * register_t cf_ra; return address
- * };
- */
-#if defined(__mips_o32) || defined(__mips_o64)
-#define CALLFRAME_SIZ (SZREG * (4 + 2))
-#define CALLFRAME_S0 0
-#elif defined(__mips_n32) || defined(__mips_n64)
-#define CALLFRAME_SIZ (SZREG * 4)
-#define CALLFRAME_S0 (CALLFRAME_SIZ - 4 * SZREG)
-#endif
-#ifndef _KERNEL
-#define CALLFRAME_GP (CALLFRAME_SIZ - 3 * SZREG)
-#endif
-#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG)
-#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG)
/*
* Endian-independent assembly-code aliases for unaligned memory accesses.
Index: head/sys/mips/mips/pm_machdep.c
===================================================================
--- head/sys/mips/mips/pm_machdep.c
+++ head/sys/mips/mips/pm_machdep.c
@@ -62,6 +62,7 @@
#include <vm/vm_extern.h>
#include <sys/user.h>
#include <sys/uio.h>
+#include <machine/abi.h>
#include <machine/cpuinfo.h>
#include <machine/reg.h>
#include <machine/md_var.h>
@@ -132,10 +133,10 @@
SIGISMEMBER(psp->ps_sigonstack, sig)) {
sfp = (struct sigframe *)(((uintptr_t)td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - sizeof(struct sigframe))
- & ~(sizeof(__int64_t) - 1));
+ & ~(STACK_ALIGN - 1));
} else
sfp = (struct sigframe *)((vm_offset_t)(regs->sp -
- sizeof(struct sigframe)) & ~(sizeof(__int64_t) - 1));
+ sizeof(struct sigframe)) & ~(STACK_ALIGN - 1));
/* Build the argument list for the signal handler. */
regs->a0 = sig;
@@ -408,12 +409,7 @@
bzero((caddr_t)td->td_frame, sizeof(struct trapframe));
- /*
- * The stack pointer has to be aligned to accommodate the largest
- * datatype at minimum. This probably means it should be 16-byte
- * aligned, but for now we're 8-byte aligning it.
- */
- td->td_frame->sp = ((register_t) stack) & ~(sizeof(__int64_t) - 1);
+ td->td_frame->sp = ((register_t)stack) & ~(STACK_ALIGN - 1);
/*
* If we're running o32 or n32 programs but have 64-bit registers,
Index: head/sys/mips/mips/vm_machdep.c
===================================================================
--- head/sys/mips/mips/vm_machdep.c
+++ head/sys/mips/mips/vm_machdep.c
@@ -59,6 +59,7 @@
#include <sys/sysctl.h>
#include <sys/unistd.h>
+#include <machine/abi.h>
#include <machine/cache.h>
#include <machine/clock.h>
#include <machine/cpu.h>
@@ -82,18 +83,6 @@
#include <sys/user.h>
#include <sys/mbuf.h>
-/* Duplicated from asm.h */
-#if defined(__mips_o32)
-#define SZREG 4
-#else
-#define SZREG 8
-#endif
-#if defined(__mips_o32) || defined(__mips_o64)
-#define CALLFRAME_SIZ (SZREG * (4 + 2))
-#elif defined(__mips_n32) || defined(__mips_n64)
-#define CALLFRAME_SIZ (SZREG * 4)
-#endif
-
/*
* Finish a fork operation, with process p2 nearly set up.
* Copy and update the pcb, set up the stack so that the child
@@ -430,13 +419,7 @@
struct trapframe *tf;
register_t sp;
- /*
- * At the point where a function is called, sp must be 8
- * byte aligned[for compatibility with 64-bit CPUs]
- * in ``See MIPS Run'' by D. Sweetman, p. 269
- * align stack
- */
- sp = (((intptr_t)stack->ss_sp + stack->ss_size) & ~0x7) -
+ sp = (((intptr_t)stack->ss_sp + stack->ss_size) & ~(STACK_ALIGN - 1)) -
CALLFRAME_SIZ;
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 25, 4:41 PM (20 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26151421
Default Alt Text
D13875.id.diff (8 KB)
Attached To
Mode
D13875: Switch to 16-byte stack alignment on N32 and N64.
Attached
Detach File
Event Timeline
Log In to Comment