Module Name: src Committed By: cherry Date: Thu Aug 11 11:01:31 UTC 2011
Modified Files: src/sys/arch/i386/i386: gdt.c Log Message: per-cpu gdt support for xen To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/arch/i386/i386/gdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/i386/i386/gdt.c diff -u src/sys/arch/i386/i386/gdt.c:1.50 src/sys/arch/i386/i386/gdt.c:1.51 --- src/sys/arch/i386/i386/gdt.c:1.50 Sat Nov 21 03:11:00 2009 +++ src/sys/arch/i386/i386/gdt.c Thu Aug 11 11:01:30 2011 @@ -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; }