Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Jan 2011 15:26:06 +0000 (UTC)
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r217056 - in stable/8/sys/i386: i386 include xen
Message-ID:  <201101061526.p06FQ65D019026@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cperciva
Date: Thu Jan  6 15:26:06 2011
New Revision: 217056
URL: http://svn.freebsd.org/changeset/base/217056

Log:
  MFC r216843-216847: Fix i386_set_ldt on i386/XEN.

Modified:
  stable/8/sys/i386/i386/sys_machdep.c
  stable/8/sys/i386/include/pmap.h
  stable/8/sys/i386/include/segments.h
  stable/8/sys/i386/xen/pmap.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/i386/i386/sys_machdep.c
==============================================================================
--- stable/8/sys/i386/i386/sys_machdep.c	Thu Jan  6 14:19:29 2011	(r217055)
+++ stable/8/sys/i386/i386/sys_machdep.c	Thu Jan  6 15:26:06 2011	(r217056)
@@ -450,6 +450,7 @@ user_ldt_alloc(struct mdproc *mdp, int l
         new_ldt->ldt_refcnt = 1; 
         new_ldt->ldt_active = 0; 
  
+	mtx_lock_spin(&dt_lock);
         if ((pldt = mdp->md_ldt)) { 
                 if (len > pldt->ldt_len) 
                         len = pldt->ldt_len; 
@@ -458,8 +459,10 @@ user_ldt_alloc(struct mdproc *mdp, int l
         } else { 
                 bcopy(ldt, new_ldt->ldt_base, PAGE_SIZE); 
         } 
+        mtx_unlock_spin(&dt_lock);  /* XXX kill once pmap locking fixed. */
         pmap_map_readonly(kernel_pmap, (vm_offset_t)new_ldt->ldt_base, 
                           new_ldt->ldt_len*sizeof(union descriptor)); 
+        mtx_lock_spin(&dt_lock);  /* XXX kill once pmap locking fixed. */
         return (new_ldt);
 } 
 #else
@@ -520,8 +523,13 @@ user_ldt_free(struct thread *td)
 	}
 
 	if (td == PCPU_GET(curthread)) {
+#ifdef XEN
+		i386_reset_ldt(&default_proc_ldt);
+		PCPU_SET(currentldt, (int)&default_proc_ldt);
+#else
 		lldt(_default_ldt);
 		PCPU_SET(currentldt, _default_ldt);
+#endif
 	}
 
 	mdp->md_ldt = NULL;
@@ -758,10 +766,14 @@ i386_set_ldt_data(struct thread *td, int
 
 	mtx_assert(&dt_lock, MA_OWNED);
 
-	/* Fill in range */
-	bcopy(descs,
-	    &((union descriptor *)(pldt->ldt_base))[start],
-	    num * sizeof(union descriptor));
+	while (num) {
+		xen_update_descriptor(
+		    &((union descriptor *)(pldt->ldt_base))[start],
+		    descs);
+		num--;
+		start++;
+		descs++;
+	}
 	return (0);
 }
 #else

Modified: stable/8/sys/i386/include/pmap.h
==============================================================================
--- stable/8/sys/i386/include/pmap.h	Thu Jan  6 14:19:29 2011	(r217055)
+++ stable/8/sys/i386/include/pmap.h	Thu Jan  6 15:26:06 2011	(r217056)
@@ -251,7 +251,6 @@ pte_load_store(pt_entry_t *ptep, pt_entr
 {
 	pt_entry_t r;
 
-	v = xpmap_ptom(v);
 	r = *ptep;
 	PT_SET_VA(ptep, v, TRUE);
 	return (r);

Modified: stable/8/sys/i386/include/segments.h
==============================================================================
--- stable/8/sys/i386/include/segments.h	Thu Jan  6 14:19:29 2011	(r217055)
+++ stable/8/sys/i386/include/segments.h	Thu Jan  6 15:26:06 2011	(r217056)
@@ -249,6 +249,7 @@ struct region_descriptor {
 #ifdef _KERNEL
 extern int	_default_ldt;
 #ifdef XEN
+extern struct proc_ldt default_proc_ldt;
 extern union descriptor *gdt;
 extern union descriptor *ldt;
 #else

Modified: stable/8/sys/i386/xen/pmap.c
==============================================================================
--- stable/8/sys/i386/xen/pmap.c	Thu Jan  6 14:19:29 2011	(r217055)
+++ stable/8/sys/i386/xen/pmap.c	Thu Jan  6 15:26:06 2011	(r217056)
@@ -3711,7 +3711,9 @@ pmap_map_readonly(pmap_t pmap, vm_offset
 	for (i = 0; i < npages; i++) {
 		pt_entry_t *pte;
 		pte = pmap_pte(pmap, (vm_offset_t)(va + i*PAGE_SIZE));
+		vm_page_lock_queues();
 		pte_store(pte, xpmap_mtop(*pte & ~(PG_RW|PG_M)));
+		vm_page_unlock_queues();
 		PMAP_MARK_PRIV(xpmap_mtop(*pte));
 		pmap_pte_release(pte);
 	}
@@ -3725,7 +3727,9 @@ pmap_map_readwrite(pmap_t pmap, vm_offse
 		pt_entry_t *pte;
 		pte = pmap_pte(pmap, (vm_offset_t)(va + i*PAGE_SIZE));
 		PMAP_MARK_UNPRIV(xpmap_mtop(*pte));
+		vm_page_lock_queues();
 		pte_store(pte, xpmap_mtop(*pte) | (PG_RW|PG_M));
+		vm_page_unlock_queues();
 		pmap_pte_release(pte);
 	}
 }



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