PERFORCE change 131862 for review
Kip Macy
kmacy at FreeBSD.org
Thu Dec 27 23:13:08 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=131862
Change 131862 by kmacy at pandemonium:kmacy:xen31 on 2007/12/28 07:12:28
move forward from crashing in pmap_pinit in create_init to crashing in
start_init as a result of xen rejecting the page table that we're attempting
to switch to
Affected files ...
.. //depot/projects/xen31/sys/i386/i386/genassym.c#4 edit
.. //depot/projects/xen31/sys/i386/i386/machdep.c#8 edit
.. //depot/projects/xen31/sys/i386/i386/swtch.s#2 edit
.. //depot/projects/xen31/sys/i386/i386/sys_machdep.c#2 edit
.. //depot/projects/xen31/sys/i386/i386/trap.c#5 edit
.. //depot/projects/xen31/sys/i386/include/asmacros.h#3 edit
.. //depot/projects/xen31/sys/i386/include/cpufunc.h#4 edit
.. //depot/projects/xen31/sys/i386/include/pcpu.h#3 edit
.. //depot/projects/xen31/sys/i386/include/pmap.h#7 edit
.. //depot/projects/xen31/sys/i386/include/xen/xenpmap.h#4 edit
.. //depot/projects/xen31/sys/i386/isa/npx.c#2 edit
.. //depot/projects/xen31/sys/i386/pci/pci_cfgreg.c#4 edit
.. //depot/projects/xen31/sys/i386/xen/locore.s#6 edit
.. //depot/projects/xen31/sys/i386/xen/pmap.c#7 edit
.. //depot/projects/xen31/sys/i386/xen/xen_machdep.c#7 edit
.. //depot/projects/xen31/sys/xen/xenbus/xenbus_comms.h#2 edit
.. //depot/projects/xen31/sys/xen/xenbus/xenbus_xs.c#3 edit
Differences ...
==== //depot/projects/xen31/sys/i386/i386/genassym.c#4 (text+ko) ====
@@ -234,5 +234,6 @@
#ifdef XEN
#include <machine/xen/xen-public/arch-x86_32.h>
+ASSYM(PC_CR3, offsetof(struct pcpu, pc_cr3));
ASSYM(HYPERVISOR_VIRT_START, __HYPERVISOR_VIRT_START);
#endif
==== //depot/projects/xen31/sys/i386/i386/machdep.c#8 (text+ko) ====
@@ -2154,6 +2154,8 @@
}
#ifdef XEN
+extern vm_paddr_t *pdir_shadow;
+
void
init386(int first)
{
@@ -2238,7 +2240,8 @@
PCPU_SET(curthread, &thread0);
PCPU_SET(curpcb, thread0.td_pcb);
PCPU_SET(pdir, (unsigned long)IdlePTD);
-
+ PCPU_SET(pdir_shadow, pdir_shadow);
+
/*
* Initialize mutexes.
*
@@ -2358,6 +2361,7 @@
dblfault_tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL);
vm86_initialize();
+ PCPU_SET(pdir_shadow, pdir_shadow);
getmemsize(first);
init_param2(physmem);
==== //depot/projects/xen31/sys/i386/i386/swtch.s#2 (text+ko) ====
@@ -88,7 +88,7 @@
movl 8(%esp),%ecx /* New thread */
movl TD_PCB(%ecx),%edx
movl PCB_CR3(%edx),%eax
- movl %eax,%cr3 /* new address space */
+ LOAD_CR3(%eax)
/* set bit in new pm_active */
movl TD_PROC(%ecx),%eax
movl P_VMSPACE(%eax), %ebx
@@ -181,10 +181,10 @@
cmpl %eax,IdlePTD /* Kernel address space? */
#endif
je sw0
- movl %cr3,%ebx /* The same address space? */
+ READ_CR3(%ebx) /* The same address space? */
cmpl %ebx,%eax
je sw0
- movl %eax,%cr3 /* new address space */
+ LOAD_CR3(%eax) /* new address space */
movl %esi,%eax
movl PCPU(CPUID),%esi
SETOP %eax,TD_LOCK(%edi) /* Switchout td_lock */
@@ -211,6 +211,18 @@
SETOP %esi,TD_LOCK(%edi) /* Switchout td_lock */
sw1:
BLOCK_SPIN(%ecx)
+#ifdef XEN
+ pushl %eax
+ pushl %ecx
+ pushl %edx
+ call xen_handle_thread_switch
+ popl %edx
+ popl %ecx
+ popl %eax
+ /*
+ * XXX set IOPL
+ */
+#else
/*
* At this point, we've switched address spaces and are ready
* to load up the rest of the next context.
@@ -259,7 +271,7 @@
movl 12(%esi), %ebx
movl %eax, 8(%edi)
movl %ebx, 12(%edi)
-
+#endif
/* Restore context. */
movl PCB_EBX(%edx),%ebx
movl PCB_ESP(%edx),%esp
@@ -285,7 +297,7 @@
movl _default_ldt,%eax
cmpl PCPU(CURRENTLDT),%eax
je 2f
- lldt _default_ldt
+ LLDT(_default_ldt)
movl %eax,PCPU(CURRENTLDT)
jmp 2f
1:
@@ -389,7 +401,7 @@
* parent's npx state for forks by forgetting to reload.
*/
pushfl
- cli
+ CLI
movl PCPU(FPCURTHREAD),%eax
testl %eax,%eax
je 1f
==== //depot/projects/xen31/sys/i386/i386/sys_machdep.c#2 (text+ko) ====
@@ -58,6 +58,20 @@
#include <security/audit/audit.h>
+
+#ifdef XEN
+#include <machine/xen/xenfunc.h>
+
+void i386_reset_ldt(struct proc_ldt *pldt);
+
+void
+i386_reset_ldt(struct proc_ldt *pldt)
+{
+ xen_set_ldt((vm_offset_t)pldt->ldt_base, pldt->ldt_len);
+}
+#else
+#define i386_reset_ldt(x)
+#endif
#include <vm/vm_kern.h> /* for kernel_map */
#define MAX_LD 8192
==== //depot/projects/xen31/sys/i386/i386/trap.c#5 (text+ko) ====
@@ -102,6 +102,13 @@
#include <machine/clock.h>
#endif
+#ifdef XEN
+#include <machine/xen/xenfunc.h>
+#include <machine/xen/hypervisor.h>
+#include <machine/xen/xenvar.h>
+#include <machine/xen/hypervisor-ifs.h>
+#endif
+
extern void trap(struct trapframe *frame);
extern void syscall(struct trapframe *frame);
@@ -130,7 +137,11 @@
"alignment fault", /* 14 T_ALIGNFLT */
"", /* 15 unused */
"", /* 16 unused */
+#ifdef XEN
+ "hypervisor callback", /* 17 T_HYPCALLBACK */
+#else
"", /* 17 unused */
+#endif
"integer divide fault", /* 18 T_DIVIDE */
"non-maskable interrupt trap", /* 19 T_NMI */
"overflow trap", /* 20 T_OFLOW */
@@ -218,6 +229,7 @@
goto out;
#endif
+#ifndef XEN
if ((frame->tf_eflags & PSL_I) == 0) {
/*
* Buggy application or kernel code has disabled
@@ -248,9 +260,18 @@
enable_intr();
}
}
-
+#endif
eva = 0;
code = frame->tf_err;
+#ifdef XEN
+ if (type == T_HYPCALLBACK) {
+ evtchn_do_upcall(frame);
+ if (ISPL(frame->tf_cs) == SEL_KPL)
+ goto out;
+ goto userout;
+ } else if (type == 0)
+ panic("invalid trap type/code %d/%d\n",type, code);
+#endif
if (type == T_PAGEFLT) {
/*
* For some Cyrix CPUs, %cr2 is clobbered by
==== //depot/projects/xen31/sys/i386/include/asmacros.h#3 (text+ko) ====
@@ -176,6 +176,35 @@
movl $KPSEL, %eax ; /* reload with per-CPU data segment */ \
movl %eax, %fs
+#ifdef XEN
+#define LOAD_CR3(reg) \
+ movl reg,PCPU(CR3); \
+ pushl %ecx ; \
+ pushl %edx ; \
+ pushl %esi ; \
+ pushl reg ; \
+ call xen_load_cr3 ; \
+ addl $4,%esp ; \
+ popl %esi ; \
+ popl %edx ; \
+ popl %ecx ; \
+
+#define READ_CR3(reg) movl PCPU(CR3),reg;
+#define LLDT(arg) \
+ pushl %edx ; \
+ pushl %eax ; \
+ xorl %eax,%eax ; \
+ movl %eax,%gs ; \
+ call i386_reset_ldt ; \
+ popl %eax ; \
+ popl %edx
+#define CLI call ni_cli
+#else
+#define LOAD_CR3(reg) movl reg,%cr3;
+#define READ_CR3(reg) movl %cr3,reg;
+#define LLDT(arg) lldt arg;
+#define CLI cli
+#endif
#endif /* LOCORE */
==== //depot/projects/xen31/sys/i386/include/cpufunc.h#4 (text+ko) ====
@@ -49,8 +49,6 @@
#include <machine/xen/evtchn.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
-#include <machine/xen/xenpmap.h>
-#include <machine/xen/xenvar.h>
struct thread;
#endif
==== //depot/projects/xen31/sys/i386/include/pcpu.h#3 (text+ko) ====
@@ -55,6 +55,7 @@
struct segment_descriptor pc_common_tssd; \
struct segment_descriptor *pc_tss_gdt; \
struct segment_descriptor *pc_fsgs_gdt; \
+ vm_paddr_t *pc_pdir_shadow; \
int pc_currentldt; \
u_int pc_acpi_id; /* ACPI CPU id */ \
u_int pc_apic_id; \
==== //depot/projects/xen31/sys/i386/include/pmap.h#7 (text+ko) ====
@@ -397,6 +397,9 @@
pdpt_entry_t *pm_pdpt; /* KVA of page director pointer
table */
#endif
+#ifdef XEN
+ vm_paddr_t *pm_pdir_shadow;
+#endif
};
typedef struct pmap *pmap_t;
==== //depot/projects/xen31/sys/i386/include/xen/xenpmap.h#4 (text+ko) ====
@@ -47,6 +47,8 @@
void xen_flush_queue(void);
void pmap_ref(pt_entry_t *pte, vm_paddr_t ma);
+#include <sys/param.h>
+#include <sys/pcpu.h>
#ifdef PMAP_DEBUG
#define PMAP_REF pmap_ref
@@ -81,7 +83,24 @@
struct pmap;
void pd_set(struct pmap *pmap, vm_paddr_t *ptr, vm_paddr_t val, int type);
+#ifdef notyet
+static vm_paddr_t
+vptetomachpte(vm_paddr_t *pte)
+{
+ vm_offset_t offset, ppte;
+ vm_paddr_t pgoffset, retval, *pdir_shadow_ptr;
+ int pgindex;
+ ppte = (vm_offset_t)pte;
+ pgoffset = (ppte & PAGE_MASK);
+ offset = ppte - (vm_offset_t)PTmap;
+ pgindex = ppte >> PDRSHIFT;
+
+ pdir_shadow_ptr = (vm_paddr_t *)PCPU_GET(pdir_shadow);
+ retval = (pdir_shadow_ptr[pgindex] & ~PAGE_MASK) + pgoffset;
+ return (retval);
+}
+#endif
#define PT_GET(_ptp) \
(pmap_valid_entry(*(_ptp)) ? xpmap_mtop(*(_ptp)) : *(_ptp))
@@ -103,7 +122,7 @@
*(_ptp) = 0; \
} while (/*CONSTCOND*/0)
-#define PD_SET_VA(_pmap, _ptp, _npte, sync) do { \
+#define PD_SET_VA(_pmap, _ptp, _npte, sync) do { \
PMAP_REF((_ptp), xpmap_ptom(_npte)); \
pd_set((_pmap),(_ptp),(_npte), SH_PD_SET_VA); \
if (sync || ALWAYS_SYNC) xen_flush_queue(); \
@@ -115,7 +134,7 @@
} while (/*CONSTCOND*/0)
#define PD_CLEAR_VA(_pmap, _ptp, sync) do { \
PMAP_REF((pt_entry_t *)(_ptp), 0); \
- pd_set((_pmap),(_ptp), 0, SH_PD_SET_VA_CLEAR); \
+ pd_set((_pmap),(_ptp), 0, SH_PD_SET_VA_CLEAR); \
if (sync || ALWAYS_SYNC) xen_flush_queue(); \
} while (/*CONSTCOND*/0)
@@ -123,18 +142,18 @@
#define PT_SET_VA(_ptp,_npte,sync) do { \
PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- xen_queue_pt_update(vtomach(_ptp), \
+ xen_queue_pt_update(vtomach(_ptp), \
xpmap_ptom(_npte)); \
if (sync || ALWAYS_SYNC) xen_flush_queue(); \
} while (/*CONSTCOND*/0)
#define PT_SET_VA_MA(_ptp,_npte,sync) do { \
PMAP_REF((_ptp), (_npte)); \
- xen_queue_pt_update(vtomach(_ptp), _npte); \
+ xen_queue_pt_update(vtomach(_ptp), _npte); \
if (sync || ALWAYS_SYNC) xen_flush_queue(); \
} while (/*CONSTCOND*/0)
#define PT_CLEAR_VA(_ptp, sync) do { \
PMAP_REF((pt_entry_t *)(_ptp), 0); \
- xen_queue_pt_update(vtomach(_ptp), 0); \
+ xen_queue_pt_update(vtomach(_ptp), 0); \
if (sync || ALWAYS_SYNC) \
xen_flush_queue(); \
} while (/*CONSTCOND*/0)
@@ -163,7 +182,7 @@
pte_t pte_t_ma; \
pte_t_ma.pte_high = (uint32_t)((_ma) >> 32); \
pte_t_ma.pte_low = (uint32_t)((_ma) & 0xFFFFFFFF); \
- PANIC_IF(HYPERVISOR_update_va_mapping(((unsigned long)_va), \
+ PANIC_IF(HYPERVISOR_update_va_mapping(((unsigned long)(_va)),\
pte_t_ma, \
UVMF_INVLPG| UVMF_LOCAL) < 0); \
} while (/*CONSTCOND*/0)
@@ -174,7 +193,7 @@
do { \
pte_t pte_t_ma; \
pte_t_ma.pte_low = (uint32_t)(_ma); \
- PANIC_IF(HYPERVISOR_update_va_mapping(((unsigned long)_va), \
+ PANIC_IF(HYPERVISOR_update_va_mapping(((unsigned long)(_va)), \
pte_t_ma, \
UVMF_INVLPG| UVMF_LOCAL) < 0); \
} while (/*CONSTCOND*/0)
==== //depot/projects/xen31/sys/i386/isa/npx.c#2 (text+ko) ====
@@ -100,9 +100,14 @@
#define fxsave(addr) __asm __volatile("fxsave %0" : "=m" (*(addr)))
#define ldmxcsr(__csr) __asm __volatile("ldmxcsr %0" : : "m" (__csr))
#endif
+#ifdef XEN
+#define start_emulating() (HYPERVISOR_fpu_taskswitch(1))
+#define stop_emulating() (HYPERVISOR_fpu_taskswitch(0))
+#else
#define start_emulating() __asm("smsw %%ax; orb %0,%%al; lmsw %%ax" \
: : "n" (CR0_TS) : "ax")
#define stop_emulating() __asm("clts")
+#endif
#else /* !(__GNUCLIKE_ASM && !lint) */
==== //depot/projects/xen31/sys/i386/pci/pci_cfgreg.c#4 (text+ko) ====
@@ -135,7 +135,10 @@
int
pci_cfgregopen(void)
{
-#ifndef XEN
+#ifdef XEN
+ return (0);
+#else
+
static int opened = 0;
u_int16_t vid, did;
u_int16_t v;
@@ -177,8 +180,8 @@
pciereg_cfgopen();
}
}
+ return (1);
#endif
- return(1);
}
/*
==== //depot/projects/xen31/sys/i386/xen/locore.s#6 (text+ko) ====
@@ -83,7 +83,7 @@
#ifdef notyet
ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
#else
- ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "pae_pgdir_above_4gb|supervisor_mode_kernel")
+ ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "pae_pgdir_above_4gb|supervisor_mode_kernel|writable_descriptor_tables")
#endif
#ifdef PAE
==== //depot/projects/xen31/sys/i386/xen/pmap.c#7 (text+ko) ====
@@ -295,7 +295,6 @@
static void pmap_pte_release(pt_entry_t *pte);
static int pmap_unuse_pt(pmap_t, vm_offset_t, vm_page_t *);
static vm_offset_t pmap_kmem_choose(vm_offset_t addr);
-static void pmap_copy_ma_range(vm_paddr_t src, vm_paddr_t dst, uint32_t soff, uint32_t eoff);
#ifdef PAE
static void *pmap_pdpt_allocf(uma_zone_t zone, int bytes, u_int8_t *flags, int wait);
@@ -386,6 +385,7 @@
#ifdef PAE
kernel_pmap->pm_pdpt = (pdpt_entry_t *) (KERNBASE + (u_int)IdlePDPT);
#endif
+ kernel_pmap->pm_pdir_shadow = PCPU_GET(pdir_shadow);
kernel_pmap->pm_active = -1; /* don't allow deactivation */
TAILQ_INIT(&kernel_pmap->pm_pvchunk);
LIST_INIT(&allpmaps);
@@ -1365,9 +1365,8 @@
int
pmap_pinit(pmap_t pmap)
{
- vm_page_t m, ptdpg[NPGPTD*2];
- vm_paddr_t ma, ma_shadow;
- int npgptd = NPGPTD*2;
+ vm_page_t m, ptdpg[NPGPTD*2 + 1];
+ int npgptd = NPGPTD*2 + 1;
static int color;
int i;
@@ -1380,12 +1379,23 @@
if (pmap->pm_pdir == NULL) {
pmap->pm_pdir = (pd_entry_t *)kmem_alloc_nofault(kernel_map,
NBPTD);
-
+ if (pmap->pm_pdir == NULL) {
+ PMAP_LOCK_DESTROY(pmap);
+ return (0);
+ }
+#ifdef XEN
+ pmap->pm_pdir_shadow = (pd_entry_t *)kmem_alloc_nofault(kernel_map,
+ NBPTD);
if (pmap->pm_pdir == NULL) {
PMAP_LOCK_DESTROY(pmap);
return (0);
}
#ifdef PAE
+ pmap->pm_pdpt = (pd_entry_t *)kmem_alloc_nofault(kernel_map, 1);
+#endif
+#endif
+
+#if defined(PAE) && !defined(XEN)
pmap->pm_pdpt = uma_zalloc(pdptzone, M_WAITOK | M_ZERO);
KASSERT(((vm_offset_t)pmap->pm_pdpt &
((NPGPTD * sizeof(pdpt_entry_t)) - 1)) == 0,
@@ -1405,60 +1415,64 @@
if (m == NULL)
VM_WAIT;
else {
-#ifdef XEN
- pmap_zero_page(m); /* is this really needed? */
-#endif
ptdpg[i++] = m;
}
}
pmap_qenter((vm_offset_t)pmap->pm_pdir, ptdpg, NPGPTD);
-#ifndef XEN
+
for (i = 0; i < NPGPTD; i++) {
if ((ptdpg[i]->flags & PG_ZERO) == 0)
bzero(pmap->pm_pdir + (i * NPDEPG), PAGE_SIZE);
}
-#endif
+
mtx_lock_spin(&allpmaps_lock);
LIST_INSERT_HEAD(&allpmaps, pmap, pm_list);
mtx_unlock_spin(&allpmaps_lock);
/* Wire in kernel global address entries. */
- /* XXX copies current process */
- bcopy(kernel_pmap->pm_pdir + KPTDI, pmap->pm_pdir + KPTDI,
- nkpt * sizeof(pd_entry_t));
+
+ bcopy(PTD + KPTDI, pmap->pm_pdir + KPTDI, nkpt * sizeof(pd_entry_t));
/* XXX need to copy global address entries to page directory's L1 shadow */
- ma = xpmap_ptom(VM_PAGE_TO_PHYS(ptdpg[NPGPTD]));
- /* L1 pin shadow page director{y,ies} */
+#ifdef PAE
+#ifdef XEN
+ pmap_qenter((vm_offset_t)pmap->pm_pdpt, &ptdpg[NPGPTD*2], 1);
+#endif
for (i = 0; i < NPGPTD; i++) {
+ vm_paddr_t ma;
+
ma = xpmap_ptom(VM_PAGE_TO_PHYS(ptdpg[NPGPTD + i]));
- pmap_copy_ma_range(kernel_pmap->pm_pdir[PTDPTDI + i] & ~(PG_RW|PG_M), ma,
- KPTDI*sizeof(pd_entry_t), nkpt*sizeof(pd_entry_t));
- xen_pt_pin(ma);
+ pmap->pm_pdpt[i] = ma | PG_V;
+
}
+#endif
+#ifdef XEN
+ pmap_qenter((vm_offset_t)pmap->pm_pdir_shadow, &ptdpg[NPGPTD], NPGPTD);
- /* pin and install L1 shadow */
+ for (i = 0; i < NPGPTD; i++)
+ if ((ptdpg[i + NPGPTD]->flags & PG_ZERO) == 0)
+ bzero(pmap->pm_pdir_shadow + (i * NPDEPG), PAGE_SIZE);
+ for (i = 0; i < NPGPTD; i++)
+ pmap->pm_pdir_shadow[PTDPTDI + i] =
+ xpmap_ptom(VM_PAGE_TO_PHYS(ptdpg[i])) | PG_V;
+ for (i = 0; i < NPGPTD; i++)
+ pmap->pm_pdir[PTDPTDI + i] =
+ xpmap_ptom(VM_PAGE_TO_PHYS(ptdpg[i + NPGPTD])) | PG_V;
+
+ bcopy(PTD + KPTDI, pmap->pm_pdir_shadow + KPTDI, nkpt * sizeof(pd_entry_t));
for (i = 0; i < NPGPTD; i++) {
- ma = xpmap_ptom(VM_PAGE_TO_PHYS(ptdpg[i]));
- ma_shadow = xpmap_ptom(VM_PAGE_TO_PHYS(ptdpg[NPGPTD+i]));
- /* re-map page directory read-only and pin */
- PT_SET_MA(pmap->pm_pdir + i*PAGE_SIZE,
- (ma | PG_V | PG_A));
- PT_SET_MA(pmap->pm_pdpt + i*PAGE_SIZE,
- (ma | PG_V | PG_A));
- xen_pgd_pin(ma);
- /* add L1 shadow of L2 */
- xen_queue_pt_update(vtomach(&pmap->pm_pdir[PTDPTDI + i]),
- ma_shadow | PG_V | PG_A);
- xen_queue_pt_update(ma_shadow + PTDPTDI*sizeof(vm_paddr_t),
- vtomach(pmap->pm_pdir) | PG_V | PG_A);
+ vm_paddr_t *pd;
-#ifdef PAE
- xen_queue_pt_update(vtomach(&pmap->pm_pdpt[i]),
- ma_shadow | PG_V | PG_A);
+ pd = pmap->pm_pdir + (i * NPDEPG);
+ PT_SET_MA(pd, *vtopte((vm_offset_t)pd) & ~PG_RW);
+ pd = pmap->pm_pdir_shadow + (i * NPDEPG);
+ PT_SET_MA(pd, *vtopte((vm_offset_t)pd) & ~PG_RW);
+ }
+#ifdef PAE
+ PT_SET_MA(pmap->pm_pdpt, *vtopte((vm_offset_t)pmap->pm_pdpt) & ~PG_RW);
#endif
- }
xen_flush_queue();
-
+#endif
+
pmap->pm_active = 0;
TAILQ_INIT(&pmap->pm_pvchunk);
bzero(&pmap->pm_stats, sizeof pmap->pm_stats);
@@ -3197,36 +3211,6 @@
mtx_unlock(&sysmaps->lock);
}
-
-
-void
-pmap_copy_ma_range(vm_paddr_t src, vm_paddr_t dst, uint32_t soff, uint32_t len)
-{
- struct sysmaps *sysmaps;
-
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
-
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP1)
- panic("pmap_copy_ma: CMAP1 busy");
- if (*sysmaps->CMAP2)
- panic("pmap_copy_ma: CMAP2 busy");
- sched_pin();
-
- invlpg((u_int)sysmaps->CADDR1);
- invlpg((u_int)sysmaps->CADDR2);
-
- PT_SET_VA_MA(sysmaps->CMAP1, PG_V | src | PG_A, FALSE);
- PT_SET_VA_MA(sysmaps->CMAP2, PG_V | PG_RW | dst | PG_A | PG_M, TRUE);
-
- bcopy(sysmaps->CADDR1 + soff, sysmaps->CADDR2 + soff, len);
- PT_CLEAR_VA(sysmaps->CMAP1, FALSE);
- PT_CLEAR_VA(sysmaps->CMAP2, TRUE);
- sched_unpin();
- mtx_unlock(&sysmaps->lock);
-}
-
-
/*
* Returns true if the pmap's pv is one of the first
* 16 pvs linked to from this page. This count may
@@ -3628,7 +3612,7 @@
pmap = PV_PMAP(pv);
PMAP_LOCK(pmap);
pte = pmap_pte_quick(pmap, pv->pv_va);
- val = PT_GET(pte);
+ val = *pte;
if ((val & PG_M) != 0) {
/*
@@ -3639,9 +3623,9 @@
#ifndef XEN
atomic_clear_int((u_int *)pte, PG_M);
#else
- PT_SET_VA(pv->pv_va, val & ~PG_M, FALSE);
+ PT_SET_MA(pv->pv_va, val & ~PG_M);
+#endif
pmap_invalidate_page(pmap, pv->pv_va);
-#endif
}
PMAP_UNLOCK(pmap);
}
@@ -3669,7 +3653,7 @@
pmap = PV_PMAP(pv);
PMAP_LOCK(pmap);
pte = pmap_pte_quick(pmap, pv->pv_va);
- val = PT_GET(pte);
+ val = *pte;
if ((val & PG_A) != 0) {
/*
* Regardless of whether a pte is 32 or 64 bits
@@ -3679,7 +3663,7 @@
#ifndef XEN
atomic_clear_int((u_int *)pte, PG_A);
#else
- PT_SET_VA(pv->pv_va, val & ~PG_A, FALSE);
+ PT_SET_MA(pv->pv_va, val & ~PG_A);
#endif
pmap_invalidate_page(pmap, pv->pv_va);
}
@@ -3763,7 +3747,7 @@
{
vm_offset_t base, offset, tmpva;
pt_entry_t *pte;
- u_int opte, npte;
+ vm_paddr_t opte, npte;
pd_entry_t *pde;
vm_paddr_t val;
@@ -3810,10 +3794,10 @@
} while (npte != opte &&
!atomic_cmpset_int((u_int *)pte, opte, npte));
#else
- opte = PT_GET(pte);
+ opte = *pte;
npte = opte & ~(PG_PTE_PAT | PG_NC_PCD | PG_NC_PWT);
npte |= pmap_cache_bits(mode, 0);
- PT_SET_VA(tmpva, npte, FALSE);
+ PT_SET_MA(tmpva, npte);
#endif
tmpva += PAGE_SIZE;
size -= PAGE_SIZE;
==== //depot/projects/xen31/sys/i386/xen/xen_machdep.c#7 (text+ko) ====
@@ -645,11 +645,7 @@
#endif
-#ifdef PAE
-static vm_paddr_t *pdir_shadow;
-#else
-static vm_paddr_t *pdir_shadow;
-#endif
+vm_paddr_t *pdir_shadow;
#ifdef ADD_ISA_HOLE
static void
==== //depot/projects/xen31/sys/xen/xenbus/xenbus_comms.h#2 (text+ko) ====
@@ -37,17 +37,27 @@
int xs_input_avail(void);
extern int xb_waitq;
-static __inline int wait_event_interruptible(void *wchan, int condition)
-{
- int ret = 0;
- for (;;) {
- if (condition)
- break;
- if ((ret = !tsleep(wchan, PWAIT | PCATCH, "waitev", hz/10)))
- break;
- }
- return ret;
-}
+#define __wait_event_interruptible(wchan, condition, ret) \
+do { \
+ for (;;) { \
+ if (condition) \
+ break; \
+ if ((ret = !tsleep(wchan, PWAIT | PCATCH, "waitev", hz/10))) \
+ break; \
+ } \
+} while (0)
+
+
+#define wait_event_interruptible(wchan, condition) \
+({ \
+ int __ret = 0; \
+ if (!(condition)) \
+ __wait_event_interruptible(wchan, condition, __ret); \
+ __ret; \
+})
+
+
+
#define DECLARE_MUTEX(lock) struct sema lock
#define semaphore sema
#define rw_semaphore sema
==== //depot/projects/xen31/sys/xen/xenbus/xenbus_xs.c#3 (text+ko) ====
@@ -48,7 +48,7 @@
#include <machine/stdarg.h>
#include <xen/xenbus/xenbus_comms.h>
-
+int xs_process_msg(void);
#define EXPORT_SYMBOL(x)
#define kmalloc(size, unused) malloc(size, M_DEVBUF, M_WAITOK)
@@ -141,6 +141,9 @@
struct xs_stored_msg *msg;
char *body;
+ if (HYPERVISOR_shared_info->evtchn_mask[curcpu] & 1)
+ xs_process_msg();
+
spin_lock(&xs_state.reply_lock);
while (list_empty(&xs_state.reply_list)) {
@@ -737,7 +740,7 @@
}
}
-static int process_msg(void)
+int xs_process_msg(void)
{
struct xs_stored_msg *msg;
char *body;
@@ -804,7 +807,7 @@
int err;
for (;;) {
- err = process_msg();
+ err = xs_process_msg();
if (err)
printf("XENBUS error %d while reading "
"message\n", err);
More information about the p4-projects
mailing list