changeset 13267:c0c901825468

536 hat_getkpfnum needs to be removed Reviewed by: gwr@nexenta.com Reviewed by: trisk@nexenta.com
author Garrett D'Amore <garrett@nexenta.com>
date Wed, 19 Jan 2011 08:06:56 -0800
parents e573198ae730
children b749961aba64
files usr/src/uts/common/Makefile.files usr/src/uts/common/vm/hat.c usr/src/uts/common/vm/hat.h usr/src/uts/i86pc/vm/hat_i86.c usr/src/uts/sfmmu/vm/hat_sfmmu.c usr/src/uts/sfmmu/vm/hat_sfmmu.h usr/src/uts/sun4/sys/fcode.h usr/src/uts/sun4u/starcat/os/starcat.c
diffstat 8 files changed, 15 insertions(+), 285 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/Makefile.files	Mon Jan 17 21:18:02 2011 -0800
+++ b/usr/src/uts/common/Makefile.files	Wed Jan 19 08:06:56 2011 -0800
@@ -190,7 +190,6 @@
 		gid.o		\
 		groups.o	\
 		grow.o		\
-		hat.o		\
 		hat_refmod.o	\
 		id32.o		\
 		id_space.o	\
@@ -1939,11 +1938,6 @@
 #
 KICONV_EMEA_OBJS += kiconv_emea.o
 
-#
-#	blk2scsa
-#
-BLK2SCSA_OBJS = blk2scsa.o
-
 KICONV_JA_OBJS += kiconv_ja.o
 
 KICONV_KO_OBJS += kiconv_cck_common.o kiconv_ko.o
--- a/usr/src/uts/common/vm/hat.c	Mon Jan 17 21:18:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/param.h>
-#include <sys/kmem.h>
-#include <sys/sysmacros.h>
-#include <sys/cmn_err.h>
-#include <sys/systm.h>
-#include <sys/modctl.h>
-#include <sys/kobj.h>
-#include <vm/hat.h>
-
-/*
- * PSARC 2004/405 made hat_getkpfnum(9F) obsolete. As part of the
- * obsolecense, the original documented behavior will begin to be
- * enforced in the future; namely, hat_getkpfnum(9F) may _only_
- * be called with device-mapped memory virtual addresses. Since
- * changing hat_getkpfnum(9F) to return PFN_INVALID on kernel memory
- * would break a lot of modules without any warning, we've implemented
- * the following mechanism as a stop-gap. In a future release, this
- * can all be ripped out and hat_getkpfnum(9F) changed to return
- * PFN_INVALID if it isn't called with a device-mapped memory address.
- *
- * We keep track of each module that has used hat_getkpfnum(9F)
- * incorrectly. This allows us to avoid flooding the console/logs
- * with too many warnings about a bad module that has already been
- * flagged.
- *
- * On amd64 hat_getkpfnum() is never supported.
- */
-
-#if !defined(__amd64)
-
-#define	HAT_STACK_MAXDEPTH	15
-
-struct badcall_node {
-	char	*bc_modname;
-	int	bc_stackdepth;
-	pc_t	bc_callstack[HAT_STACK_MAXDEPTH];
-	struct badcall_node *bc_linkage;
-};
-
-static struct badcall_node *bad_getkpfnum_callers;
-
-/*
- * Common VM HAT routines.
- */
-
-static void
-printwarn(struct badcall_node *bc)
-{
-	int sf;
-	char *ksym;
-	ulong_t off;
-
-	cmn_err(CE_WARN, "Module %s is using the obsolete hat_getkpfnum(9F)",
-	    bc->bc_modname);
-	cmn_err(CE_CONT, "interface in a way that will not be supported in\n");
-	cmn_err(CE_CONT, "a future release of Solaris. Please contact the\n");
-	cmn_err(CE_CONT, "vendor that supplied the module for assistance,\n");
-	cmn_err(CE_CONT, "or consult the Writing Device Drivers guide,\n");
-	cmn_err(CE_CONT, "available from http://www.sun.com for migration\n");
-	cmn_err(CE_CONT, "advice.\n");
-	cmn_err(CE_CONT, "---\n");
-	cmn_err(CE_CONT, "Callstack of bad caller:\n");
-
-	for (sf = 0; sf < bc->bc_stackdepth; sf++) {
-		ksym = kobj_getsymname(bc->bc_callstack[sf], &off);
-		cmn_err(CE_CONT, "\t%s+%lx\n", ksym? ksym : "?", off);
-	}
-}
-
-
-void
-hat_getkpfnum_badcall(void *caller)
-{
-	struct badcall_node bcs;
-	char *modname = mod_containing_pc((caddr_t)caller);
-	struct badcall_node *bc;
-
-#ifdef	__sparc
-	/*
-	 * This is a hack until the ifb and jfb framebuffer drivers
-	 * are fixed. Right now they use hat_getkpfnum() in a way that
-	 * is really safe but will be incorrectly flagged as being
-	 * buggy.
-	 */
-	if (strcmp(modname, "ifb") == 0 || strcmp(modname, "jfb") == 0)
-		return;
-#elif defined(__i386)
-	/*
-	 * This is a hack until these ethernet drivers can be fixed
-	 * or EOL'd.  hat_getkpfnum() will continue to work correctly
-	 * until this list can be removed.
-	 */
-	if (strcmp(modname, "dnet") == 0 || strcmp(modname, "pcn") == 0 ||
-	    strcmp(modname, "adp") == 0)
-		return;
-#endif	/* __sparc / __i386 */
-
-	for (bc = bad_getkpfnum_callers; bc != NULL; bc = bc->bc_linkage)
-		if (strcmp(bc->bc_modname, modname) == 0)
-			return;
-
-	/*
-	 * We haven't seen this caller before, so create a log of
-	 * the callstack and module name, and emit a warning to the
-	 * user.
-	 */
-	bc = kmem_zalloc(sizeof (struct badcall_node), KM_NOSLEEP);
-	if (bc != NULL) {
-		bc->bc_linkage = bad_getkpfnum_callers;
-		bc->bc_modname = modname;
-		bad_getkpfnum_callers = bc;
-	} else {
-		bc = &bcs;
-		bc->bc_modname = modname;
-	}
-
-	bc->bc_stackdepth = getpcstack(bc->bc_callstack, HAT_STACK_MAXDEPTH);
-
-	printwarn(bc);
-}
-#endif /* __amd64 */
--- a/usr/src/uts/common/vm/hat.h	Mon Jan 17 21:18:02 2011 -0800
+++ b/usr/src/uts/common/vm/hat.h	Wed Jan 19 08:06:56 2011 -0800
@@ -181,10 +181,6 @@
  * pfn_t hat_getpfnum(hat, addr)
  *	returns pfn for <hat, addr> or PFN_INVALID if mapping is invalid.
  *
- * pfn_t hat_getkpfnum(addr)
- *	returns pfn for non-memory mapped addr in kernel address space
- *	or PFN_INVALID if mapping is invalid or is kernel memory.
- *
  * int hat_probe(hat, addr)
  *	return 0 if no valid mapping is present.  Faster version
  *	of hat_getattr in certain architectures.
@@ -239,15 +235,6 @@
 uint64_t va_to_pa(void *);
 
 /*
- * hat_getkpfnum() is never supported on amd64 and will be
- * removed from other platforms in future release
- */
-#if !defined(__amd64)
-pfn_t	hat_getkpfnum(caddr_t);
-#endif
-
-
-/*
  * Kernel Physical Mapping (segkpm) hat interface routines.
  */
 caddr_t	hat_kpm_mapin(struct page *, struct kpme *);
@@ -519,13 +506,6 @@
 void	hat_resvstat(size_t, struct as *, caddr_t);
 
 /*
- * Transitionary routine while we still allow hat_getkpfnum(caddr_t)
- * to return a pfn for kernel memory, but want to warn the user that
- * it isn't supported.
- */
-void	hat_getkpfnum_badcall(void *caller);
-
-/*
  * Relocation callback routines. Currently only sfmmu HAT supports
  * these.
  */
--- a/usr/src/uts/i86pc/vm/hat_i86.c	Mon Jan 17 21:18:02 2011 -0800
+++ b/usr/src/uts/i86pc/vm/hat_i86.c	Wed Jan 19 08:06:56 2011 -0800
@@ -25,7 +25,9 @@
  * Copyright (c) 2010, Intel Corporation.
  * All rights reserved.
  */
-
+/*
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ */
 
 /*
  * VM - Hardware Address Translation management for i386 and amd64
@@ -2806,46 +2808,6 @@
 }
 
 /*
- * hat_getkpfnum() is an obsolete DDI routine, and its use is discouraged.
- * Use hat_getpfnum(kas.a_hat, ...) instead.
- *
- * We'd like to return PFN_INVALID if the mappings have underlying page_t's
- * but can't right now due to the fact that some software has grown to use
- * this interface incorrectly. So for now when the interface is misused,
- * return a warning to the user that in the future it won't work in the
- * way they're abusing it, and carry on.
- *
- * Note that hat_getkpfnum() is never supported on amd64.
- */
-#if !defined(__amd64)
-pfn_t
-hat_getkpfnum(caddr_t addr)
-{
-	pfn_t	pfn;
-	int badcaller = 0;
-
-	if (khat_running == 0)
-		panic("hat_getkpfnum(): called too early\n");
-	if ((uintptr_t)addr < kernelbase)
-		return (PFN_INVALID);
-
-	XPV_DISALLOW_MIGRATE();
-	if (segkpm && IS_KPM_ADDR(addr)) {
-		badcaller = 1;
-		pfn = hat_kpm_va2pfn(addr);
-	} else {
-		pfn = hat_getpfnum(kas.a_hat, addr);
-		badcaller = pf_is_memory(pfn);
-	}
-
-	if (badcaller)
-		hat_getkpfnum_badcall(caller());
-	XPV_ALLOW_MIGRATE();
-	return (pfn);
-}
-#endif /* __amd64 */
-
-/*
  * int hat_probe(hat, addr)
  *	return 0 if no valid mapping is present.  Faster version
  *	of hat_getattr in certain architectures.
--- a/usr/src/uts/sfmmu/vm/hat_sfmmu.c	Mon Jan 17 21:18:02 2011 -0800
+++ b/usr/src/uts/sfmmu/vm/hat_sfmmu.c	Wed Jan 19 08:06:56 2011 -0800
@@ -21,6 +21,9 @@
 /*
  * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  */
+/*
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ */
 
 /*
  * VM - Hardware Address Translation management for Spitfire MMU.
@@ -372,14 +375,6 @@
 static id_t sfmmu_tsb_cb_id;
 struct sfmmu_callback *sfmmu_cb_table;
 
-/*
- * Kernel page relocation is enabled by default for non-caged
- * kernel pages.  This has little effect unless segkmem_reloc is
- * set, since by default kernel memory comes from inside the
- * kernel cage.
- */
-int hat_kpr_enabled = 1;
-
 kmutex_t	kpr_mutex;
 kmutex_t	kpr_suspendlock;
 kthread_t	*kreloc_thread;
@@ -6876,7 +6871,7 @@
 	int		cflags = 0;
 #endif
 
-	if (hat_kpr_enabled == 0 || !kcage_on || PP_ISNORELOC(*target)) {
+	if (!kcage_on || PP_ISNORELOC(*target)) {
 		PAGE_RELOCATE_LOG(target, replacement, EAGAIN, -1);
 		return (EAGAIN);
 	}
@@ -7922,7 +7917,7 @@
 	if (hat_check_vtop == 0)
 		return;
 
-	if (hat_kpr_enabled == 0 || kvseg.s_base == NULL || panicstr)
+	if (kvseg.s_base == NULL || panicstr)
 		return;
 
 	pp = page_numtopp_nolock(pfn);
@@ -8014,57 +8009,6 @@
 }
 
 /*
- * hat_getkpfnum() is an obsolete DDI routine, and its use is discouraged.
- * Use hat_getpfnum(kas.a_hat, ...) instead.
- *
- * We'd like to return PFN_INVALID if the mappings have underlying page_t's
- * but can't right now due to the fact that some software has grown to use
- * this interface incorrectly. So for now when the interface is misused,
- * return a warning to the user that in the future it won't work in the
- * way they're abusing it, and carry on (after disabling page relocation).
- */
-pfn_t
-hat_getkpfnum(caddr_t addr)
-{
-	pfn_t pfn;
-	tte_t tte;
-	int badcaller = 0;
-	extern int segkmem_reloc;
-
-	if (segkpm && IS_KPM_ADDR(addr)) {
-		badcaller = 1;
-		pfn = sfmmu_kpm_vatopfn(addr);
-	} else {
-		while ((pfn = sfmmu_vatopfn(addr, ksfmmup, &tte))
-		    == PFN_SUSPENDED) {
-			sfmmu_vatopfn_suspended(addr, ksfmmup, &tte);
-		}
-		badcaller = pf_is_memory(pfn);
-	}
-
-	if (badcaller) {
-		/*
-		 * We can't return PFN_INVALID or the caller may panic
-		 * or corrupt the system.  The only alternative is to
-		 * disable page relocation at this point for all kernel
-		 * memory.  This will impact any callers of page_relocate()
-		 * such as FMA or DR.
-		 *
-		 * RFE: Add junk here to spit out an ereport so the sysadmin
-		 * can be advised that he should upgrade his device driver
-		 * so that this doesn't happen.
-		 */
-		hat_getkpfnum_badcall(caller());
-		if (hat_kpr_enabled && segkmem_reloc) {
-			hat_kpr_enabled = 0;
-			segkmem_reloc = 0;
-			cmn_err(CE_WARN, "Kernel Page Relocation is DISABLED");
-		}
-	}
-	return (pfn);
-}
-
-/*
  * This routine will return both pfn and tte for the vaddr.
  */
 static pfn_t
--- a/usr/src/uts/sfmmu/vm/hat_sfmmu.h	Mon Jan 17 21:18:02 2011 -0800
+++ b/usr/src/uts/sfmmu/vm/hat_sfmmu.h	Wed Jan 19 08:06:56 2011 -0800
@@ -1084,8 +1084,6 @@
 extern int sfmmu_max_cb_id;
 extern struct sfmmu_callback *sfmmu_cb_table;
 
-extern int hat_kpr_enabled;
-
 struct pa_hment;
 
 /*
--- a/usr/src/uts/sun4/sys/fcode.h	Mon Jan 17 21:18:02 2011 -0800
+++ b/usr/src/uts/sun4/sys/fcode.h	Wed Jan 19 08:06:56 2011 -0800
@@ -26,8 +26,6 @@
 #ifndef	_SYS_FCODE_H
 #define	_SYS_FCODE_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <sys/sysmacros.h>
 #include <sys/ddi.h>
 #include <sys/sunddi.h>
@@ -160,7 +158,7 @@
 /*
  * FC_GET_FCODE_DATA: This ioctl allows userland portion of the fcode
  * interpreter to get the fcode into a local buffer without having
- * to use mmap() interface (which calls hat_getkpfnum() routine).
+ * to use mmap() interface.
  * This allows DR kernel cage memory to be relocated while this
  * fcode buffer is allocated.
  *
--- a/usr/src/uts/sun4u/starcat/os/starcat.c	Mon Jan 17 21:18:02 2011 -0800
+++ b/usr/src/uts/sun4u/starcat/os/starcat.c	Wed Jan 19 08:06:56 2011 -0800
@@ -23,6 +23,10 @@
  * Use is subject to license terms.
  */
 
+/*
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ */
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/sysmacros.h>
@@ -178,7 +182,7 @@
 	/*
 	 * KPR (kernel page relocation) is supported on this platform.
 	 */
-	if (hat_kpr_enabled && kernel_cage_enable && ncpunode >= 32) {
+	if (kernel_cage_enable && ncpunode >= 32) {
 		segkmem_reloc = 1;
 		cmn_err(CE_NOTE, "!Kernel Page Relocation is ENABLED");
 	} else {
@@ -1318,8 +1322,7 @@
 {
 	extern int segkmem_reloc;
 
-	if (hat_kpr_enabled && kernel_cage_enable &&
-	    (ncpunode >= 32 || segkmem_reloc == 1))
+	if (kernel_cage_enable && (ncpunode >= 32 || segkmem_reloc == 1))
 		return (0);
 
 	return (1);