Module Name:    src
Committed By:   martin
Date:           Thu Nov 14 12:11:13 UTC 2013

Modified Files:
        src/sys/arch/sparc64/include: elf_machdep.h types.h
        src/sys/arch/sparc64/sparc64: machdep.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/include/elf_machdep.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sparc64/include/types.h
cvs rdiff -u -r1.272 -r1.273 src/sys/arch/sparc64/sparc64/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/include/elf_machdep.h
diff -u src/sys/arch/sparc64/include/elf_machdep.h:1.10 src/sys/arch/sparc64/include/elf_machdep.h:1.11
--- src/sys/arch/sparc64/include/elf_machdep.h:1.10	Sat May 30 05:56:53 2009
+++ src/sys/arch/sparc64/include/elf_machdep.h	Thu Nov 14 12:11:13 2013
@@ -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 */

Index: src/sys/arch/sparc64/include/types.h
diff -u src/sys/arch/sparc64/include/types.h:1.25 src/sys/arch/sparc64/include/types.h:1.26
--- src/sys/arch/sparc64/include/types.h:1.25	Sun Dec 11 12:19:10 2005
+++ src/sys/arch/sparc64/include/types.h	Thu Nov 14 12:11:13 2013
@@ -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

Index: src/sys/arch/sparc64/sparc64/machdep.c
diff -u src/sys/arch/sparc64/sparc64/machdep.c:1.272 src/sys/arch/sparc64/sparc64/machdep.c:1.273
--- src/sys/arch/sparc64/sparc64/machdep.c:1.272	Mon Feb  4 22:19:43 2013
+++ src/sys/arch/sparc64/sparc64/machdep.c	Thu Nov 14 12:11:13 2013
@@ -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 @@ mm_md_readwrite(dev_t dev, struct uio *u
 
 	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

Reply via email to