Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Apr 2003 13:28:42 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 29365 for review
Message-ID:  <200304212028.h3LKSg2v082838@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=29365

Change 29365 by marcel@marcel_nfs on 2003/04/21 13:27:48

	Use a non-trapping implementation for pmap_kextract.
	This has been deliberately made non-inlined for now
	to help profiling, debugging and whatsnot. Be extra
	careful (probably over-correctingly so :-) with the
	address passed to us, because it may be an address
	given to use from user space.
	
	Note that an inlined or partially inlined version
	should be used eventually. It appears that UMA is
	a regular user of pmap_kextract and rudimentary
	testing showed that it's mostly for direct mapped
	KVAs. Doing the test for direct mapped KVAs inlined
	will probably be worth it.
	
	Valuable insights by: jake

Affected files ...

.. //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#6 edit
.. //depot/projects/ia64_epc/sys/ia64/include/pmap.h#4 edit

Differences ...

==== //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#6 (text+ko) ====

@@ -125,6 +125,9 @@
 #include <machine/pal.h>
 #include <machine/md_var.h>
 
+/* XXX move to a header. */
+extern u_int64_t ia64_gateway_page[];
+
 MALLOC_DEFINE(M_PMAP, "PMAP", "PMAP Structures");
 
 #ifndef KSTACK_MAX_PAGES
@@ -1309,6 +1312,37 @@
 }
 
 /*
+ * Extract the physical page address associated with a kernel
+ * virtual address.
+ */
+vm_paddr_t
+pmap_kextract(vm_offset_t va)
+{
+	struct ia64_lpte *pte;
+	vm_offset_t gwpage;
+
+	KASSERT(va >= IA64_RR_BASE(5), ("Must be kernel VA"));
+
+	/* Regions 6 and 7 are direct mapped. */
+	if (va >= IA64_RR_BASE(6))
+		return (IA64_RR_MASK(va));
+
+	/* EPC gateway page? */
+	gwpage = (vm_offset_t)ia64_get_k5();
+	if (va >= gwpage && va < gwpage + PAGE_SIZE)
+		return (IA64_RR_MASK((vm_offset_t)ia64_gateway_page));
+
+	/* Bail out if the virtual address is beyond our limits. */
+	if (IA64_RR_MASK(va) >= nkpt * PAGE_SIZE * NKPTEPG)
+		return (0);
+
+	pte = pmap_find_kpte(va);
+	if (!pte->pte_p)
+		return (0);
+	return ((pte->pte_ppn << 12) | (va & PAGE_MASK));
+}
+
+/*
  * Add a list of wired pages to the kva
  * this routine is only used for temporary
  * kernel mappings that do not need to have

==== //depot/projects/ia64_epc/sys/ia64/include/pmap.h#4 (text+ko) ====

@@ -59,14 +59,6 @@
 #endif
 #define MAXKPT		(PAGE_SIZE/sizeof(vm_offset_t))
 
-/*
- *	Routine:	pmap_kextract
- *	Function:
- *		Extract the physical page address associated
- *		kernel virtual address.
- */
-#define	pmap_kextract	ia64_tpa
-
 #define	vtophys(va)	pmap_kextract(((vm_offset_t) (va)))
 
 #endif /* _KERNEL */
@@ -127,6 +119,7 @@
 vm_offset_t pmap_steal_memory(vm_size_t);
 void	pmap_bootstrap(void);
 void	pmap_kenter(vm_offset_t va, vm_offset_t pa);
+vm_paddr_t pmap_kextract(vm_offset_t va);
 void	pmap_kremove(vm_offset_t);
 void	pmap_setdevram(unsigned long long basea, vm_offset_t sizea);
 int	pmap_uses_prom_console(void);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304212028.h3LKSg2v082838>