PERFORCE change 161164 for review

Marko Zec zec at FreeBSD.org
Mon Apr 27 08:19:52 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=161164

Change 161164 by zec at zec_amdx2 on 2009/04/27 08:19:05

	Suffle positioning of vi_symlookup() in kern_vimage.c and
	restore a comment - diff reduction against head.

Affected files ...

.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#83 edit

Differences ...

==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#83 (text+ko) ====

@@ -80,35 +80,6 @@
 static int vnet_mod_constructor(struct vnet_modlink *);
 static int vnet_mod_destructor(struct vnet_modlink *);
 
-int
-vi_symlookup(struct kld_sym_lookup *lookup, char *symstr)
-{
-	struct vnet_modlink *vml;
-	struct vnet_symmap *mapentry;
-
-	TAILQ_FOREACH(vml, &vnet_modlink_head, vml_mod_le) {
-
-		if (vml->vml_modinfo->vmi_symmap == NULL)
-			continue;
-
-		for (mapentry = vml->vml_modinfo->vmi_symmap;
-		     mapentry->name != NULL; mapentry++) {
-			if (strcmp(symstr, mapentry->name) == 0) {
-#ifdef VIMAGE
-				lookup->symvalue =
-				    (u_long) curvnet->mod_data[vml->vml_modinfo->vmi_id];
-				lookup->symvalue += mapentry->offset;
-#else
-				lookup->symvalue = (u_long) mapentry->offset;
-#endif
-				lookup->symsize = mapentry->size;
-				return (0);
-			}
-		}
-	}
-	return (ENOENT);
-}
-
 void
 vnet_mod_register(const struct vnet_modinfo *vmi)
 {
@@ -129,6 +100,7 @@
 	if (vml_iter != NULL)
 		panic("registering an already registered vnet module: %s",
 		    vml_iter->vml_modinfo->vmi_name);
+	vml = malloc(sizeof(struct vnet_modlink), M_VIMAGE, M_NOWAIT);
 
 	/*
 	 * XXX we support only statically assigned module IDs at the time.
@@ -145,7 +117,6 @@
 	if ((iarg == NULL) ^ (iname == NULL))
 		panic("invalid vnet module instance: %s", vmi->vmi_name);
 
-	vml = malloc(sizeof(struct vnet_modlink), M_VIMAGE, M_NOWAIT);
 	vml->vml_modinfo = vmi;
 	vml->vml_iarg = iarg;
 	vml->vml_iname = iname;
@@ -302,6 +273,41 @@
 
 	return (0);
 }
+
+/*
+ * vi_symlookup() attempts to resolve name to address queries for
+ * variables which have been moved from global namespace to virtualization
+ * container structures, but are still directly accessed from legacy
+ * userspace processes via kldsym(2) and kmem(4) interfaces.
+ */
+int
+vi_symlookup(struct kld_sym_lookup *lookup, char *symstr)
+{
+	struct vnet_modlink *vml;
+	struct vnet_symmap *mapentry;
+
+	TAILQ_FOREACH(vml, &vnet_modlink_head, vml_mod_le) {
+
+		if (vml->vml_modinfo->vmi_symmap == NULL)
+			continue;
+
+		for (mapentry = vml->vml_modinfo->vmi_symmap;
+		     mapentry->name != NULL; mapentry++) {
+			if (strcmp(symstr, mapentry->name) == 0) {
+#ifdef VIMAGE
+				lookup->symvalue =
+				    (u_long) curvnet->mod_data[vml->vml_modinfo->vmi_id];
+				lookup->symvalue += mapentry->offset;
+#else
+				lookup->symvalue = (u_long) mapentry->offset;
+#endif
+				lookup->symsize = mapentry->size;
+				return (0);
+			}
+		}
+	}
+	return (ENOENT);
+}
 #endif /* !VIMAGE_GLOBALS */
 
 #ifdef VIMAGE


More information about the p4-projects mailing list