Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/i386 per-cpu gdt support for xen



details:   https://anonhg.NetBSD.org/src/rev/fe17ed3e9690
branches:  trunk
changeset: 768192:fe17ed3e9690
user:      cherry <cherry%NetBSD.org@localhost>
date:      Thu Aug 11 11:01:30 2011 +0000

description:
per-cpu gdt support for xen

diffstat:

 sys/arch/i386/i386/gdt.c |  41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diffs (77 lines):

diff -r be1df6c14b75 -r fe17ed3e9690 sys/arch/i386/i386/gdt.c
--- a/sys/arch/i386/i386/gdt.c  Thu Aug 11 10:52:12 2011 +0000
+++ b/sys/arch/i386/i386/gdt.c  Thu Aug 11 11:01:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.c,v 1.50 2009/11/21 03:11:00 rmind Exp $   */
+/*     $NetBSD: gdt.c,v 1.51 2011/08/11 11:01:30 cherry Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.50 2009/11/21 03:11:00 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.51 2011/08/11 11:01:30 cherry Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -207,17 +207,28 @@
                KASSERT(va >= VM_MIN_KERNEL_ADDRESS);
                ptp = kvtopte(va);
                frames[f] = *ptp >> PAGE_SHIFT;
-               pmap_pte_clearbits(ptp, PG_RW);
+               { 
+                  /* 
+                   * pmap_pte_clearbits(ptp, PG_RW);
+                   * but without spl(), since %fs is not setup
+                   * properly yet, ie; curcpu() won't work at this
+                   * point and spl() will break.
+                   */
+                  xpq_queue_lock();
+                  xpq_queue_pte_update(xpmap_ptetomach(ptp),
+                                       *ptp & ~PG_RW);
+                  xpq_flush_queue();
+                  xpq_queue_unlock();
+               }
        }
-       /* printk("loading gdt %x, %d entries, %d pages", */
-           /* frames[0] << PAGE_SHIFT, gdt_size[0], len >> PAGE_SHIFT); */
+
        if (HYPERVISOR_set_gdt(frames, gdt_size[0]))
                panic("HYPERVISOR_set_gdt failed!\n");
        lgdt_finish();
 #endif
 }
 
-#ifdef MULTIPROCESSOR
+#if defined(MULTIPROCESSOR) && !defined(XEN)
 
 void
 gdt_reload_cpu(struct cpu_info *ci)
@@ -255,15 +266,17 @@
                        gdt_size[which] = MINGDTSIZ;
                        new_len = gdt_size[which] * sizeof(gdt[0]);
                }
-               for(va = (vaddr_t)(cpu_info_primary.ci_gdt) + old_len + max_len;
-                   va < (vaddr_t)(cpu_info_primary.ci_gdt) + new_len + max_len;
-                   va += PAGE_SIZE) {
-                       while ((pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO))
-                           == NULL) {
-                               uvm_wait("gdt_grow");
+               for (CPU_INFO_FOREACH(cii, ci)) {
+                       for(va = (vaddr_t)(ci->ci_gdt) + old_len + max_len;
+                           va < (vaddr_t)(ci->ci_gdt) + new_len + max_len;
+                           va += PAGE_SIZE) {
+                               while ((pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO))
+                                      == NULL) {
+                                       uvm_wait("gdt_grow");
+                               }
+                               pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg),
+                                              VM_PROT_READ | VM_PROT_WRITE, 0);
                        }
-                       pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg),
-                           VM_PROT_READ | VM_PROT_WRITE, 0);
                }
                return;
        }



Home | Main Index | Thread Index | Old Index