Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64 Allow TOPDOWN-VM only for binaries compiled...



details:   https://anonhg.NetBSD.org/src/rev/d158cf89d3e7
branches:  trunk
changeset: 791365:d158cf89d3e7
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Nov 14 12:11:13 2013 +0000

description:
Allow TOPDOWN-VM only for binaries compiled with appropriate code model.
No change yet, as __HAVE_TOPDOWN is not yet defined.

diffstat:

 sys/arch/sparc64/include/elf_machdep.h |  13 ++++++++++++-
 sys/arch/sparc64/include/types.h       |   6 +++++-
 sys/arch/sparc64/sparc64/machdep.c     |  25 +++++++++++++++++++++++--
 3 files changed, 40 insertions(+), 4 deletions(-)

diffs (82 lines):

diff -r 18be7123e825 -r d158cf89d3e7 sys/arch/sparc64/include/elf_machdep.h
--- a/sys/arch/sparc64/include/elf_machdep.h    Thu Nov 14 12:07:11 2013 +0000
+++ b/sys/arch/sparc64/include/elf_machdep.h    Thu Nov 14 12:11:13 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elf_machdep.h,v 1.10 2009/05/30 05:56:53 skrll Exp $   */
+/*     $NetBSD: elf_machdep.h,v 1.11 2013/11/14 12:11:13 martin Exp $  */
 
 #define ELF32_MACHDEP_ENDIANNESS       ELFDATA2MSB
 #define        ELF32_MACHDEP_ID_CASES                                          \
@@ -21,6 +21,17 @@
 #define ARCH_ELFSIZE           32      /* MD native binary size */
 #endif
 
+#ifdef __arch64__
+/*
+ * we need to check .note.netbsd.mcmodel in native binaries before enabling
+ * top-down VM.
+ */
+struct exec_package;
+void sparc64_elf_mcmodel_check(struct exec_package*, const char *, size_t);
+#define        ELF_MD_MCMODEL_CHECK(ep, str, len)      \
+       sparc64_elf_mcmodel_check(ep,str,len)
+#endif
+
 /* The following are what is used for AT_SUN_HWCAP: */
 #define AV_SPARC_HWMUL_32x32   1       /* 32x32-bit smul/umul is efficient */
 #define        AV_SPARC_HWDIV_32x32    2       /* 32x32-bit sdiv/udiv is efficient */
diff -r 18be7123e825 -r d158cf89d3e7 sys/arch/sparc64/include/types.h
--- a/sys/arch/sparc64/include/types.h  Thu Nov 14 12:07:11 2013 +0000
+++ b/sys/arch/sparc64/include/types.h  Thu Nov 14 12:11:13 2013 +0000
@@ -1,3 +1,7 @@
-/*       $NetBSD: types.h,v 1.25 2005/12/11 12:19:10 christos Exp $        */
+/*       $NetBSD: types.h,v 1.26 2013/11/14 12:11:13 martin Exp $        */
 
 #include <sparc/types.h>
+
+#ifdef __arch64__
+#define        MD_TOPDOWN_INIT(epp)    /* no topdown VM flag for exec by default */
+#endif
diff -r 18be7123e825 -r d158cf89d3e7 sys/arch/sparc64/sparc64/machdep.c
--- a/sys/arch/sparc64/sparc64/machdep.c        Thu Nov 14 12:07:11 2013 +0000
+++ b/sys/arch/sparc64/sparc64/machdep.c        Thu Nov 14 12:11:13 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.272 2013/02/04 22:19:43 macallan Exp $ */
+/*     $NetBSD: machdep.c,v 1.273 2013/11/14 12:11:13 martin Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.272 2013/02/04 22:19:43 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.273 2013/11/14 12:11:13 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -2749,3 +2749,24 @@
 
        return ENXIO;
 }
+
+#ifdef __arch64__
+void
+sparc64_elf_mcmodel_check(struct exec_package *epp, const char *model,
+    size_t len)
+{
+       /* no model specific execution for 32bit processes */
+       if (epp->ep_flags & EXEC_32)
+               return;
+
+#ifdef __USING_TOPDOWN_VM
+       /*
+        * we allow TOPDOWN_VM for all processes where the binary is compiled
+        * with the medany or medmid code model.
+        */
+       if (strncmp(model, "medany", len) == 0 ||
+           strncmp(model, "medmid", len) == 0)
+               epp->ep_flags |= EXEC_TOPDOWN_VM;
+#endif
+}
+#endif



Home | Main Index | Thread Index | Old Index