svn commit: r185638 - in user/dfr/xenhvm/6/sys: dev/xen/xenpci xen
Doug Rabson
dfr at FreeBSD.org
Fri Dec 5 07:26:19 PST 2008
Author: dfr
Date: Fri Dec 5 15:26:19 2008
New Revision: 185638
URL: http://svn.freebsd.org/changeset/base/185638
Log:
Don't use pmap_mapdev to map HVM memory areas - this is ordinary physical
memory and we shouldn't use uncacheable mappings for it. Also, don't leak
virtual address space when the grant table size increases.
Modified:
user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c
user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h
user/dfr/xenhvm/6/sys/xen/gnttab.c
Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c
==============================================================================
--- user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c Fri Dec 5 15:00:59 2008 (r185637)
+++ user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c Fri Dec 5 15:26:19 2008 (r185638)
@@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
#include <vm/pmap.h>
#include <dev/xen/xenpci/xenpcivar.h>
@@ -248,7 +250,8 @@ static int
xenpci_attach(device_t device, struct xenpci_softc * scp)
{
struct xen_add_to_physmap xatp;
- u_long shared_pa;
+ vm_offset_t shared_va;
+ vm_paddr_t shared_pa;
if (xenpci_allocate_resources(device))
goto errexit;
@@ -269,7 +272,9 @@ xenpci_attach(device_t device, struct xe
if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
panic("HYPERVISOR_memory_op failed");
- HYPERVISOR_shared_info = pmap_mapdev(shared_pa, PAGE_SIZE);
+ shared_va = kmem_alloc_nofault(kernel_map, PAGE_SIZE);
+ pmap_kenter(shared_va, shared_pa);
+ HYPERVISOR_shared_info = (void *) shared_va;
/*
* Hook the irq up to evtchn
@@ -379,7 +384,8 @@ xenpci_deallocate_resources(device_t dev
}
static int
-xenpci_alloc_space_int(struct xenpci_softc *scp, size_t sz, u_long *pa)
+xenpci_alloc_space_int(struct xenpci_softc *scp, size_t sz,
+ vm_paddr_t *pa)
{
if (scp->phys_next + sz > rman_get_end(scp->res_memory)) {
@@ -393,7 +399,7 @@ xenpci_alloc_space_int(struct xenpci_sof
}
int
-xenpci_alloc_space(size_t sz, u_long *pa)
+xenpci_alloc_space(size_t sz, vm_paddr_t *pa)
{
device_t device = devclass_get_device(xenpci_devclass, 0);
Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h
==============================================================================
--- user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h Fri Dec 5 15:00:59 2008 (r185637)
+++ user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h Fri Dec 5 15:26:19 2008 (r185638)
@@ -36,8 +36,8 @@ struct xenpci_softc {
struct resource* res_irq; /* Resource for irq range. */
void *intr_cookie;
- u_long phys_next; /* next page from mem range */
+ vm_paddr_t phys_next; /* next page from mem range */
};
extern int xenpci_irq_init(device_t device, struct xenpci_softc *scp);
-extern int xenpci_alloc_space(size_t sz, u_long *pa);
+extern int xenpci_alloc_space(size_t sz, vm_paddr_t *pa);
Modified: user/dfr/xenhvm/6/sys/xen/gnttab.c
==============================================================================
--- user/dfr/xenhvm/6/sys/xen/gnttab.c Fri Dec 5 15:00:59 2008 (r185637)
+++ user/dfr/xenhvm/6/sys/xen/gnttab.c Fri Dec 5 15:26:19 2008 (r185638)
@@ -529,7 +529,7 @@ gnttab_suspend(void)
#include <dev/xen/xenpci/xenpcivar.h>
-static unsigned long resume_frames;
+static vm_paddr_t resume_frames;
static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
{
@@ -549,7 +549,19 @@ static int gnttab_map(unsigned int start
panic("HYPERVISOR_memory_op failed to map gnttab");
} while (i-- > start_idx);
- shared = pmap_mapdev(resume_frames, (end_idx + 1) * PAGE_SIZE);
+ if (shared == NULL) {
+ vm_offset_t area;
+
+ area = kmem_alloc_nofault(kernel_map,
+ PAGE_SIZE * max_nr_grant_frames());
+ KASSERT(area, ("can't allocate VM space for grant table"));
+ shared = (grant_entry_t *)area;
+ }
+
+ for (i = start_idx; i <= end_idx; i++) {
+ pmap_kenter((vm_offset_t) shared + i * PAGE_SIZE,
+ resume_frames + i * PAGE_SIZE);
+ }
return (0);
}
More information about the svn-src-user
mailing list