Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/arch/aarch64/aarch64 Pull up following revision(s) (r...



details:   https://anonhg.NetBSD.org/src/rev/88ee14424df7
branches:  netbsd-9
changeset: 964250:88ee14424df7
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jan 01 13:06:39 2021 +0000

description:
Pull up following revision(s) (requested by rin in ticket #1174):

        sys/arch/aarch64/aarch64/vm_machdep.c: revision 1.9 (patch)

Fix clone(2) for COMPAT_NETBSD32.
(1) Set r13 (sp for arm32 processes) appropriately when stack is
     specified to fork1().
(2) For arm32 processes, align stack to 8-byte boundary, instead of
     16-byte for native aarch64 processes, to match our 32-bit ABI:
https://nxr.netbsd.org/xref/src/sys/arch/arm/arm32/vm_machdep.c#150

Note that sp alignment checking is disabled in aarch32 mode, and
this works fine with AARCH64_EL0_STACK_ALIGNMENT_CHECK option.

OK ryo

diffstat:

 sys/arch/aarch64/aarch64/vm_machdep.c |  22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diffs (45 lines):

diff -r 36b2055929aa -r 88ee14424df7 sys/arch/aarch64/aarch64/vm_machdep.c
--- a/sys/arch/aarch64/aarch64/vm_machdep.c     Fri Jan 01 13:04:08 2021 +0000
+++ b/sys/arch/aarch64/aarch64/vm_machdep.c     Fri Jan 01 13:06:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.5 2018/12/27 09:55:27 mrg Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.5.4.1 2021/01/01 13:06:39 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -29,8 +29,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_compat_netbsd32.h"
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.5 2018/12/27 09:55:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.5.4.1 2021/01/01 13:06:39 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -116,11 +118,19 @@
        *utf = *l1->l_md.md_utf;
 
        /*
-        * If specified, give the child a different stack
-        * (make sure it's 16-byte aligned).
+        * If specified, give the child a different stack (make sure it's
+        * 16- or 8-byte aligned for 64- or 32-bit processes, respectively).
         */
-       if (stack != NULL)
-               utf->tf_sp = ((vaddr_t)(stack) + stacksize) & -16;
+       if (stack != NULL) {
+               utf->tf_sp = (vaddr_t)(stack) + stacksize;
+#ifdef COMPAT_NETBSD32
+               if (__predict_false(l2->l_proc->p_flag & PK_32)) {
+                       utf->tf_sp &= -8;
+                       utf->tf_reg[13] = utf->tf_sp;
+               } else
+#endif
+                       utf->tf_sp &= -16;
+       }
 
        /* build a new switchframe */
        struct trapframe * const ktf = utf - 1;



Home | Main Index | Thread Index | Old Index