Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/cherry-xenmp]: src/sys/arch grow MP support for i386. boots to single user
details: https://anonhg.NetBSD.org/src/rev/efbf10e955dd
branches: cherry-xenmp
changeset: 765620:efbf10e955dd
user: cherry <cherry%NetBSD.org@localhost>
date: Sun Jul 31 20:49:10 2011 +0000
description:
grow MP support for i386. boots to single user
diffstat:
sys/arch/amd64/amd64/db_interface.c | 6 +-
sys/arch/i386/i386/db_interface.c | 16 ++-
sys/arch/i386/i386/gdt.c | 23 ++-
sys/arch/i386/i386/machdep.c | 48 +++++-
sys/arch/i386/include/intrdefs.h | 5 +-
sys/arch/i386/include/pmap.h | 14 +-
sys/arch/i386/isa/npx.c | 8 +-
sys/arch/x86/x86/pmap.c | 50 +++---
sys/arch/x86/x86/pmap_tlb.c | 10 +-
sys/arch/xen/conf/std.xen | 4 +-
sys/arch/xen/x86/cpu.c | 240 +++++++++++++++++++----------------
sys/arch/xen/x86/x86_xpmap.c | 11 +-
sys/arch/xen/x86/xen_ipi.c | 49 ++++++-
sys/arch/xen/x86/xenfunc.c | 9 +-
14 files changed, 319 insertions(+), 174 deletions(-)
diffs (truncated from 1059 to 300 lines):
diff -r 9df07ebe5e48 -r efbf10e955dd sys/arch/amd64/amd64/db_interface.c
--- a/sys/arch/amd64/amd64/db_interface.c Mon Jul 25 17:29:43 2011 +0000
+++ b/sys/arch/amd64/amd64/db_interface.c Sun Jul 31 20:49:10 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.23.2.1 2011/06/03 13:27:37 cherry Exp $ */
+/* $NetBSD: db_interface.c,v 1.23.2.2 2011/07/31 20:49:10 cherry Exp $ */
/*
* Mach Operating System
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.23.2.1 2011/06/03 13:27:37 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.23.2.2 2011/07/31 20:49:10 cherry Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -82,7 +82,9 @@
#ifdef MULTIPROCESSOR
extern void ddb_ipi(struct trapframe);
static void ddb_suspend(struct trapframe *);
+#ifndef XEN
int ddb_vec;
+#endif /* XEN */
static bool ddb_mp_online;
#endif
diff -r 9df07ebe5e48 -r efbf10e955dd sys/arch/i386/i386/db_interface.c
--- a/sys/arch/i386/i386/db_interface.c Mon Jul 25 17:29:43 2011 +0000
+++ b/sys/arch/i386/i386/db_interface.c Sun Jul 31 20:49:10 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.66 2011/04/03 22:29:26 dyoung Exp $ */
+/* $NetBSD: db_interface.c,v 1.66.2.1 2011/07/31 20:49:10 cherry Exp $ */
/*
* Mach Operating System
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.66 2011/04/03 22:29:26 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.66.2.1 2011/07/31 20:49:10 cherry Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -86,7 +86,9 @@
extern void ddb_ipi(int, struct trapframe);
extern void ddb_ipi_tss(struct i386tss *);
static void ddb_suspend(struct trapframe *);
+#ifndef XEN
int ddb_vec;
+#endif /* XEN */
static bool ddb_mp_online;
#endif
@@ -104,8 +106,12 @@
{
#ifdef MULTIPROCESSOR
+#ifndef XEN
ddb_vec = idt_vec_alloc(0xf0, 0xff);
idt_vec_set(ddb_vec, &Xintrddbipi);
+#else
+ /* Initialised as part of xen_ipi_init() */
+#endif /* XEN */
#endif
}
@@ -119,8 +125,10 @@
int cpu_me = cpu_number();
int win;
+#ifndef XEN
if (ddb_vec == 0)
return 1;
+#endif /* XEN */
__cpu_simple_lock(&db_lock);
if (ddb_cpu == NOCPU)
@@ -128,7 +136,11 @@
win = (ddb_cpu == cpu_me);
__cpu_simple_unlock(&db_lock);
if (win) {
+#ifdef XEN
+ xen_broadcast_ipi(XEN_IPI_DDB);
+#else
x86_ipi(ddb_vec, LAPIC_DEST_ALLEXCL, LAPIC_DLMODE_FIXED);
+#endif /* XEN */
}
ddb_mp_online = x86_mp_online;
x86_mp_online = false;
diff -r 9df07ebe5e48 -r efbf10e955dd sys/arch/i386/i386/gdt.c
--- a/sys/arch/i386/i386/gdt.c Mon Jul 25 17:29:43 2011 +0000
+++ b/sys/arch/i386/i386/gdt.c Sun Jul 31 20:49:10 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.50.10.1 2011/07/31 20:49:10 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.50.10.1 2011/07/31 20:49:10 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)
diff -r 9df07ebe5e48 -r efbf10e955dd sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Mon Jul 25 17:29:43 2011 +0000
+++ b/sys/arch/i386/i386/machdep.c Sun Jul 31 20:49:10 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.702.2.1 2011/06/23 14:19:14 cherry Exp $ */
+/* $NetBSD: machdep.c,v 1.702.2.2 2011/07/31 20:49:10 cherry Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.702.2.1 2011/06/23 14:19:14 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.702.2.2 2011/07/31 20:49:10 cherry Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -949,8 +949,12 @@
}
#ifdef MULTIPROCESSOR
+#ifdef XEN
+ xen_broadcast_ipi(XEN_IPI_HALT);
+#else /* XEN */
x86_broadcast_ipi(X86_IPI_HALT);
-#endif
+#endif /* XEN */
+#endif /* MULTIPROCESSOR */
if (howto & RB_HALT) {
#if NACPICA > 0
@@ -1123,14 +1127,18 @@
int xen_idt_idx;
#endif
-#ifndef XEN
void cpu_init_idt(void)
{
+#ifndef XEN
struct region_descriptor region;
setregion(®ion, pentium_idt, NIDT * sizeof(idt[0]) - 1);
lidt(®ion);
+#else /* XEN */
+ XENPRINTF(("HYPERVISOR_set_trap_table %p\n", xen_idt));
+ if (HYPERVISOR_set_trap_table(xen_idt))
+ panic("HYPERVISOR_set_trap_table %p failed\n", xen_idt);
+#endif /* !XEN */
}
-#endif /* !XEN */
void
initgdt(union descriptor *tgdt)
@@ -1166,7 +1174,30 @@
lgdt(®ion);
#else /* !XEN */
frames[0] = xpmap_ptom((uint32_t)gdt - KERNBASE) >> PAGE_SHIFT;
- pmap_kenter_pa((vaddr_t)gdt, (uint32_t)gdt - KERNBASE, VM_PROT_READ, 0);
+ { /*
+ * Enter the gdt page RO into the kernel map. We can't
+ * use pmap_kenter_pa() here, because %fs is not
+ * usable until the gdt is loaded, and %fs is used as
+ * the base pointer for curcpu() and curlwp(), both of
+ * which are in the callpath of pmap_kenter_pa().
+ * So we mash up our own - this is MD code anyway.
+ *
+ * XXX: review this once we have finegrained locking
+ * for xpq.
+ */
+ pt_entry_t *pte, npte;
+ pt_entry_t pg_nx = (cpu_feature[2] & CPUID_NOX ? PG_NX : 0);
+
+ pte = kvtopte((vaddr_t)gdt);
+ npte = pmap_pa2pte((paddr_t)gdt - KERNBASE);
+ npte |= PG_RO | pg_nx | PG_V;
+
+ xpq_queue_lock();
+ xpq_queue_pte_update(xpmap_ptetomach(pte), npte);
+ xpq_flush_queue();
+ xpq_queue_unlock();
+ }
+
XENPRINTK(("loading gdt %lx, %d entries\n", frames[0] << PAGE_SHIFT,
NGDT));
if (HYPERVISOR_set_gdt(frames, NGDT /* XXX is it right ? */))
@@ -1579,10 +1610,7 @@
xen_idt[xen_idt_idx].address = (uint32_t)&IDTVEC(svr4_fasttrap);
xen_idt_idx++;
lldt(GSEL(GLDT_SEL, SEL_KPL));
-
- XENPRINTF(("HYPERVISOR_set_trap_table %p\n", xen_idt));
- if (HYPERVISOR_set_trap_table(xen_idt))
- panic("HYPERVISOR_set_trap_table %p failed\n", xen_idt);
+ cpu_init_idt();
#endif /* XEN */
init386_ksyms();
diff -r 9df07ebe5e48 -r efbf10e955dd sys/arch/i386/include/intrdefs.h
--- a/sys/arch/i386/include/intrdefs.h Mon Jul 25 17:29:43 2011 +0000
+++ b/sys/arch/i386/include/intrdefs.h Sun Jul 31 20:49:10 2011 +0000
@@ -1,3 +1,6 @@
-/* $NetBSD: intrdefs.h,v 1.3 2003/02/26 21:29:01 fvdl Exp $ */
+/* $NetBSD: intrdefs.h,v 1.3.140.1 2011/07/31 20:49:11 cherry Exp $ */
#include <x86/intrdefs.h>
+#ifdef XEN
+#include <xen/intrdefs.h>
+#endif /* XEN */
diff -r 9df07ebe5e48 -r efbf10e955dd sys/arch/i386/include/pmap.h
--- a/sys/arch/i386/include/pmap.h Mon Jul 25 17:29:43 2011 +0000
+++ b/sys/arch/i386/include/pmap.h Sun Jul 31 20:49:10 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.109 2011/02/01 20:09:08 chuck Exp $ */
+/* $NetBSD: pmap.h,v 1.109.2.1 2011/07/31 20:49:11 cherry Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -369,7 +369,9 @@
pmap_pte_set(pt_entry_t *pte, pt_entry_t npte)
{
int s = splvm();
+ xpq_queue_lock();
xpq_queue_pte_update(xpmap_ptetomach(pte), npte);
+ xpq_queue_unlock();
splx(s);
}
@@ -377,12 +379,14 @@
pmap_pte_cas(volatile pt_entry_t *ptep, pt_entry_t o, pt_entry_t n)
{
int s = splvm();
+ xpq_queue_lock();
pt_entry_t opte = *ptep;
if (opte == o) {
xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(ptep)), n);
xpq_flush_queue();
}
+ xpq_queue_unlock();
splx(s);
return opte;
}
@@ -391,10 +395,12 @@
pmap_pte_testset(volatile pt_entry_t *pte, pt_entry_t npte)
{
int s = splvm();
+ xpq_queue_lock();
pt_entry_t opte = *pte;
xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)),
npte);
xpq_flush_queue();
+ xpq_queue_unlock();
splx(s);
return opte;
}
@@ -403,8 +409,10 @@
pmap_pte_setbits(volatile pt_entry_t *pte, pt_entry_t bits)
Home |
Main Index |
Thread Index |
Old Index