PERFORCE change 46420 for review
John Baldwin
jhb at FreeBSD.org
Tue Feb 3 08:22:24 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=46420
Change 46420 by jhb at jhb_slimer on 2004/02/03 08:21:53
IFC @46414.
Affected files ...
.. //depot/projects/smpng/sys/alpha/osf1/osf1_misc.c#24 integrate
.. //depot/projects/smpng/sys/amd64/acpica/madt.c#3 integrate
.. //depot/projects/smpng/sys/amd64/amd64/cpu_switch.S#8 integrate
.. //depot/projects/smpng/sys/amd64/amd64/db_trace.c#4 integrate
.. //depot/projects/smpng/sys/amd64/amd64/fpu.c#4 integrate
.. //depot/projects/smpng/sys/amd64/amd64/genassym.c#10 integrate
.. //depot/projects/smpng/sys/amd64/amd64/local_apic.c#3 integrate
.. //depot/projects/smpng/sys/amd64/amd64/machdep.c#20 integrate
.. //depot/projects/smpng/sys/amd64/amd64/mp_machdep.c#6 integrate
.. //depot/projects/smpng/sys/amd64/amd64/pmap.c#21 integrate
.. //depot/projects/smpng/sys/amd64/amd64/trap.c#15 integrate
.. //depot/projects/smpng/sys/amd64/amd64/vm_machdep.c#14 integrate
.. //depot/projects/smpng/sys/amd64/conf/GENERIC#13 integrate
.. //depot/projects/smpng/sys/amd64/include/cpufunc.h#6 integrate
.. //depot/projects/smpng/sys/amd64/include/fpu.h#2 integrate
.. //depot/projects/smpng/sys/amd64/include/md_var.h#8 integrate
.. //depot/projects/smpng/sys/amd64/include/pcb.h#6 integrate
.. //depot/projects/smpng/sys/amd64/include/reg.h#4 integrate
.. //depot/projects/smpng/sys/amd64/include/smp.h#3 integrate
.. //depot/projects/smpng/sys/amd64/include/specialreg.h#5 integrate
.. //depot/projects/smpng/sys/amd64/isa/atpic.c#4 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_misc.c#6 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_proto.h#6 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_syscall.h#6 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_syscalls.c#6 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_sysent.c#6 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/syscalls.master#6 integrate
.. //depot/projects/smpng/sys/compat/ndis/kern_ndis.c#7 integrate
.. //depot/projects/smpng/sys/compat/ndis/subr_ndis.c#7 integrate
.. //depot/projects/smpng/sys/conf/files.i386#53 integrate
.. //depot/projects/smpng/sys/conf/files.powerpc#17 integrate
.. //depot/projects/smpng/sys/conf/majors#34 integrate
.. //depot/projects/smpng/sys/conf/systags.sh#2 integrate
.. //depot/projects/smpng/sys/dev/aac/aac.c#33 integrate
.. //depot/projects/smpng/sys/dev/aac/aac_pci.c#27 integrate
.. //depot/projects/smpng/sys/dev/aac/aacvar.h#20 integrate
.. //depot/projects/smpng/sys/dev/acpica/acpi_thermal.c#22 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-all.c#46 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-all.h#23 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-chipset.c#29 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-lowlevel.c#9 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-pci.h#18 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-queue.c#7 integrate
.. //depot/projects/smpng/sys/dev/firewire/firewire.c#30 integrate
.. //depot/projects/smpng/sys/dev/firewire/fwohci.c#30 integrate
.. //depot/projects/smpng/sys/dev/firewire/fwohci_pci.c#24 integrate
.. //depot/projects/smpng/sys/dev/firewire/fwohcireg.h#12 integrate
.. //depot/projects/smpng/sys/dev/gem/if_gem_pci.c#13 integrate
.. //depot/projects/smpng/sys/dev/hifn/hifn7751.c#14 integrate
.. //depot/projects/smpng/sys/dev/if_ndis/if_ndis.c#7 integrate
.. //depot/projects/smpng/sys/dev/isp/isp_target.c#11 integrate
.. //depot/projects/smpng/sys/dev/sound/driver.c#2 integrate
.. //depot/projects/smpng/sys/dev/usb/umass.c#34 integrate
.. //depot/projects/smpng/sys/dev/usb/uscanner.c#19 integrate
.. //depot/projects/smpng/sys/geom/geom_event.c#25 integrate
.. //depot/projects/smpng/sys/geom/geom_mirror.c#7 integrate
.. //depot/projects/smpng/sys/geom/geom_subr.c#36 integrate
.. //depot/projects/smpng/sys/i386/conf/GENERIC#46 integrate
.. //depot/projects/smpng/sys/i386/conf/NOTES#75 integrate
.. //depot/projects/smpng/sys/i386/i386/local_apic.c#7 integrate
.. //depot/projects/smpng/sys/i386/i386/longrun.c#2 integrate
.. //depot/projects/smpng/sys/i386/i386/machdep.c#72 integrate
.. //depot/projects/smpng/sys/i386/i386/pmap.c#57 integrate
.. //depot/projects/smpng/sys/i386/i386/trap.c#67 integrate
.. //depot/projects/smpng/sys/kern/init_sysent.c#40 integrate
.. //depot/projects/smpng/sys/kern/kern_mac.c#34 integrate
.. //depot/projects/smpng/sys/kern/kern_mutex.c#76 integrate
.. //depot/projects/smpng/sys/kern/kern_sig.c#85 integrate
.. //depot/projects/smpng/sys/kern/kern_subr.c#29 integrate
.. //depot/projects/smpng/sys/kern/kern_switch.c#35 integrate
.. //depot/projects/smpng/sys/kern/kern_synch.c#64 integrate
.. //depot/projects/smpng/sys/kern/sched_4bsd.c#22 integrate
.. //depot/projects/smpng/sys/kern/sched_ule.c#25 integrate
.. //depot/projects/smpng/sys/kern/subr_witness.c#111 integrate
.. //depot/projects/smpng/sys/kern/sys_pipe.c#41 integrate
.. //depot/projects/smpng/sys/kern/syscalls.c#40 integrate
.. //depot/projects/smpng/sys/kern/syscalls.master#39 integrate
.. //depot/projects/smpng/sys/kern/uipc_mbuf.c#24 integrate
.. //depot/projects/smpng/sys/kern/uipc_sem.c#9 integrate
.. //depot/projects/smpng/sys/kern/uipc_socket.c#46 integrate
.. //depot/projects/smpng/sys/kern/uipc_syscalls.c#45 integrate
.. //depot/projects/smpng/sys/kern/vfs_mount.c#23 integrate
.. //depot/projects/smpng/sys/net/if.c#41 integrate
.. //depot/projects/smpng/sys/net/if_gre.c#14 integrate
.. //depot/projects/smpng/sys/netgraph/ng_source.c#5 integrate
.. //depot/projects/smpng/sys/netinet/ip_gre.c#11 integrate
.. //depot/projects/smpng/sys/netinet/ip_icmp.c#24 integrate
.. //depot/projects/smpng/sys/netinet/ip_input.c#47 integrate
.. //depot/projects/smpng/sys/netinet/udp_usrreq.c#37 integrate
.. //depot/projects/smpng/sys/nfsclient/nfs_vfsops.c#33 integrate
.. //depot/projects/smpng/sys/opencrypto/cryptodev.h#7 integrate
.. //depot/projects/smpng/sys/opencrypto/cryptosoft.c#6 integrate
.. //depot/projects/smpng/sys/pc98/conf/GENERIC#39 integrate
.. //depot/projects/smpng/sys/pc98/conf/NOTES#21 integrate
.. //depot/projects/smpng/sys/posix4/_semaphore.h#2 integrate
.. //depot/projects/smpng/sys/posix4/semaphore.h#5 integrate
.. //depot/projects/smpng/sys/powerpc/include/vmparam.h#2 integrate
.. //depot/projects/smpng/sys/powerpc/powermac/openpic_macio.c#2 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/pmap.c#35 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/uma_machdep.c#1 branch
.. //depot/projects/smpng/sys/security/mac/mac_pipe.c#5 integrate
.. //depot/projects/smpng/sys/security/mac_biba/mac_biba.c#24 integrate
.. //depot/projects/smpng/sys/security/mac_lomac/mac_lomac.c#19 integrate
.. //depot/projects/smpng/sys/security/mac_mls/mac_mls.c#23 integrate
.. //depot/projects/smpng/sys/security/mac_stub/mac_stub.c#5 integrate
.. //depot/projects/smpng/sys/security/mac_test/mac_test.c#19 integrate
.. //depot/projects/smpng/sys/sys/mac.h#24 integrate
.. //depot/projects/smpng/sys/sys/mac_policy.h#20 integrate
.. //depot/projects/smpng/sys/sys/mount.h#25 integrate
.. //depot/projects/smpng/sys/sys/param.h#54 integrate
.. //depot/projects/smpng/sys/sys/pipe.h#7 integrate
.. //depot/projects/smpng/sys/sys/sched.h#8 integrate
.. //depot/projects/smpng/sys/sys/socket.h#16 integrate
.. //depot/projects/smpng/sys/sys/syscall.h#40 integrate
.. //depot/projects/smpng/sys/sys/syscall.mk#40 integrate
.. //depot/projects/smpng/sys/sys/sysproto.h#42 integrate
.. //depot/projects/smpng/sys/sys/uio.h#14 integrate
.. //depot/projects/smpng/sys/ufs/ffs/ffs_vnops.c#25 integrate
.. //depot/projects/smpng/sys/vm/swap_pager.c#40 integrate
.. //depot/projects/smpng/sys/vm/uma_core.c#41 integrate
.. //depot/projects/smpng/sys/vm/vm_glue.c#36 integrate
.. //depot/projects/smpng/sys/vm/vm_map.c#53 integrate
.. //depot/projects/smpng/sys/vm/vm_zeroidle.c#14 integrate
Differences ...
==== //depot/projects/smpng/sys/alpha/osf1/osf1_misc.c#24 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/alpha/osf1/osf1_misc.c,v 1.43 2003/08/17 06:42:08 marcel Exp $");
+__FBSDID("$FreeBSD: src/sys/alpha/osf1/osf1_misc.c,v 1.44 2004/02/02 12:57:49 phk Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -683,16 +683,7 @@
}
-#if 1
#define bsd2osf_dev(dev) (umajor(dev) << 20 | uminor(dev))
-#define osf2bsd_dev(dev) umakedev((umajor(dev) >> 20) & 0xfff, uminor(dev) & 0xfffff)
-#else
-#define minor(x) ((int)((x)&0xffff00ff))
-#define major(x) ((int)(((u_int)(x) >> 8)&0xff))
-#define makedev(x,y) ((dev_t)(((x) << 8) | (y)))
-#define bsd2osf_dev(dev) (major(dev) << 20 | minor(dev))
-#define osf2bsd_dev(dev) makedev(((dev) >> 20) & 0xfff, (dev) & 0xfffff)
-#endif
/*
* Convert from a stat structure to an osf1 stat structure.
*/
@@ -728,19 +719,7 @@
struct thread *td;
struct osf1_mknod_args *uap;
{
-#if notanymore
- struct mknod_args a;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
- a.path = uap->path;
- a.mode = uap->mode;
- a.dev = osf2bsd_dev(uap->dev);
-
- return mknod(td, &a);
-#endif
printf("osf1_mknod no longer implemented\n");
return ENOSYS;
}
==== //depot/projects/smpng/sys/amd64/acpica/madt.c#3 (text+ko) ====
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/acpica/madt.c,v 1.10 2003/12/09 03:04:19 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/acpica/madt.c,v 1.11 2004/01/30 00:24:45 peter Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -320,13 +320,22 @@
}
/*
- * Run through the MP table enumerating I/O APICs.
+ * Enumerate I/O APICs and setup interrupt sources.
*/
static int
madt_setup_io(void)
{
int i;
+ /* Try to initialize ACPI so that we can access the FADT. */
+ i = acpi_Startup();
+ if (ACPI_FAILURE(i)) {
+ printf("MADT: ACPI Startup failed with %s\n",
+ AcpiFormatException(i));
+ printf("Try disabling either ACPI or apic support.\n");
+ panic("Using MADT but ACPI doesn't work");
+ }
+
/* First, we run through adding I/O APIC's. */
madt_walk_table(madt_parse_apics, NULL);
@@ -523,6 +532,7 @@
{
void *new_ioapic, *old_ioapic;
u_int new_pin, old_pin;
+ int force_lo;
if (bootverbose)
printf("MADT: intr override: source %u, irq %u\n",
@@ -535,9 +545,27 @@
return;
}
+ /*
+ * If the SCI is remapped to a non-ISA global interrupt,
+ * force it to level trigger and active-lo polarity.
+ * If the SCI is identity mapped but has edge trigger and
+ * active-hi polarity, also force it to use level/lo.
+ */
+ force_lo = 0;
+ if (intr->Source == AcpiGbl_FADT->SciInt)
+ if (intr->Interrupt > 15 || (intr->Interrupt == intr->Source &&
+ intr->TriggerMode == TRIGGER_EDGE &&
+ intr->Polarity == POLARITY_ACTIVE_HIGH))
+ force_lo = 1;
+
if (intr->Source != intr->Interrupt) {
- /* XXX: This assumes that the SCI uses IRQ 9. */
- if (intr->Interrupt > 15 && intr->Source == 9)
+ /*
+ * If the SCI is remapped to a non-ISA global interrupt,
+ * then override the vector we use to setup and allocate
+ * the interrupt.
+ */
+ if (intr->Interrupt > 15 &&
+ intr->Source == AcpiGbl_FADT->SciInt)
acpi_OverrideInterruptLevel(intr->Interrupt);
else
ioapic_remap_vector(new_ioapic, new_pin, intr->Source);
@@ -549,10 +577,18 @@
intr->Source)
ioapic_disable_pin(old_ioapic, old_pin);
}
- ioapic_set_triggermode(new_ioapic, new_pin,
- interrupt_trigger(intr->TriggerMode));
- ioapic_set_polarity(new_ioapic, new_pin,
- interrupt_polarity(intr->Polarity));
+ if (force_lo) {
+ printf(
+ "MADT: Forcing active-lo polarity and level trigger for IRQ %d\n",
+ intr->Source);
+ ioapic_set_polarity(new_ioapic, new_pin, 0);
+ ioapic_set_triggermode(new_ioapic, new_pin, 0);
+ } else {
+ ioapic_set_polarity(new_ioapic, new_pin,
+ interrupt_polarity(intr->Polarity));
+ ioapic_set_triggermode(new_ioapic, new_pin,
+ interrupt_trigger(intr->TriggerMode));
+ }
}
/*
==== //depot/projects/smpng/sys/amd64/amd64/cpu_switch.S#8 (text+ko) ====
@@ -34,10 +34,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/amd64/amd64/cpu_switch.S,v 1.145 2004/01/23 01:04:28 peter Exp $
+ * $FreeBSD: src/sys/amd64/amd64/cpu_switch.S,v 1.146 2004/01/29 00:02:54 peter Exp $
*/
#include <machine/asmacros.h>
+#include <machine/specialreg.h>
#include "assym.s"
@@ -130,16 +131,36 @@
movl %fs,PCB_FS(%r8)
movl %gs,PCB_GS(%r8)
+ /* Test if debug registers should be saved. */
+ testl $PCB_DBREGS,PCB_FLAGS(%r8)
+ jz 1f /* no, skip over */
+ movq %dr7,%rax /* yes, do the save */
+ movq %rax,PCB_DR7(%r8)
+ andq $0x0000fc00, %rax /* disable all watchpoints */
+ movq %rax,%dr7
+ movq %dr6,%rax
+ movq %rax,PCB_DR6(%r8)
+ movq %dr3,%rax
+ movq %rax,PCB_DR3(%r8)
+ movq %dr2,%rax
+ movq %rax,PCB_DR2(%r8)
+ movq %dr1,%rax
+ movq %rax,PCB_DR1(%r8)
+ movq %dr0,%rax
+ movq %rax,PCB_DR0(%r8)
+1:
+
/* have we used fp, and need a save? */
cmpq %rdi,PCPU(FPCURTHREAD)
jne 1f
- pushq %rdi
- pushq %rsi
- addq $PCB_SAVEFPU,%r8 /* h/w bugs make saving complicated */
- movq %r8, %rdi
- call fpusave /* do it in a big C function */
- popq %rsi
- popq %rdi
+ addq $PCB_SAVEFPU,%r8
+ clts
+ fxsave (%r8)
+ smsw %ax
+ orb $CR0_TS,%al
+ lmsw %ax
+ xorq %rax,%rax
+ movq %rax,PCPU(FPCURTHREAD)
1:
/* Save is done. Now fire up new thread. Leave old vmspace. */
@@ -148,12 +169,19 @@
jz badsw3 /* no, panic */
#endif
movq TD_PCB(%rsi),%r8
- movl PCPU(CPUID), %eax
/* switch address space */
movq PCB_CR3(%r8),%rdx
+#ifdef LAZY_SWITCH
+ cmpq %rdx,KPML4phys /* Kernel address space? */
+ je sw1
+#endif
+ movq %cr3,%rax
+ cmpq %rdx,%rax /* Same address space? */
+ je sw1
movq %rdx,%cr3 /* new address space */
+ movl PCPU(CPUID), %eax
/* Release bit from old pmap->pm_active */
movq TD_PROC(%rdi), %rdx /* oldproc */
movq P_VMSPACE(%rdx), %rdx
@@ -223,6 +251,28 @@
movq %r8, PCPU(CURPCB)
movq %rsi, PCPU(CURTHREAD) /* into next thread */
+ /* Test if debug registers should be restored. */
+ testl $PCB_DBREGS,PCB_FLAGS(%r8)
+ jz 1f
+ movq PCB_DR6(%r8),%rax
+ movq %rax,%dr6
+ movq PCB_DR3(%r8),%rax
+ movq %rax,%dr3
+ movq PCB_DR2(%r8),%rax
+ movq %rax,%dr2
+ movq PCB_DR1(%r8),%rax
+ movq %rax,%dr1
+ movq PCB_DR0(%r8),%rax
+ movq %rax,%dr0
+ /* But preserve reserved bits in %dr7 */
+ movq %dr7,%rax
+ andq $0x0000fc00,%rax
+ movq PCB_DR7(%r8),%rcx
+ andq $~0x0000fc00,%rcx
+ orq %rcx,%rax
+ movq %rax,%dr7
+1:
+
ret
#ifdef INVARIANTS
@@ -242,7 +292,9 @@
pushq %r13
pushq %r14
pushq %r15
- pushq $sw0_1
+ movq $0,%rdi
+ movq $0,%rsi
+ leaq sw0_1,%rdx
call __panic
sw0_1: .asciz "cpu_throw: no newthread supplied"
@@ -262,7 +314,9 @@
pushq %r13
pushq %r14
pushq %r15
- pushq $sw0_2
+ movq $0,%rdi
+ movq $0,%rsi
+ leaq sw0_2,%rdx
call __panic
sw0_2: .asciz "cpu_switch: no curthread supplied"
@@ -282,7 +336,9 @@
pushq %r13
pushq %r14
pushq %r15
- pushq $sw0_3
+ movq $0,%rdi
+ movq $0,%rsi
+ leaq sw0_3,%rdx
call __panic
sw0_3: .asciz "cpu_switch: no newthread supplied"
#endif
@@ -332,17 +388,17 @@
testq %rax,%rax
je 1f
- pushq %rcx
- pushq %rax
movq TD_PCB(%rax),%rdi
leaq PCB_SAVEFPU(%rdi),%rdi
- call fpusave
- popq %rax
- popq %rcx
+ clts
+ fxsave (%rdi)
+ smsw %ax
+ orb $CR0_TS,%al
+ lmsw %ax
movq $PCB_SAVEFPU_SIZE,%rdx /* arg 3 */
leaq PCB_SAVEFPU(%rcx),%rsi /* arg 2 */
- movq %rax,%rdi /* arg 1 */
+ /* arg 1 (%rdi) already loaded */
call bcopy
1:
popfq
==== //depot/projects/smpng/sys/amd64/amd64/db_trace.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/db_trace.c,v 1.59 2003/11/17 08:58:12 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/db_trace.c,v 1.60 2004/01/28 23:57:40 peter Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -46,7 +46,6 @@
#include <ddb/db_sym.h>
#include <ddb/db_variables.h>
-#if 0
db_varfcn_t db_dr0;
db_varfcn_t db_dr1;
db_varfcn_t db_dr2;
@@ -55,7 +54,6 @@
db_varfcn_t db_dr5;
db_varfcn_t db_dr6;
db_varfcn_t db_dr7;
-#endif
/*
* Machine register set.
@@ -87,7 +85,6 @@
{ "r15", &ddb_regs.tf_r15, FCN_NULL },
{ "rip", &ddb_regs.tf_rip, FCN_NULL },
{ "rflags", &ddb_regs.tf_rflags, FCN_NULL },
-#if 0
{ "dr0", NULL, db_dr0 },
{ "dr1", NULL, db_dr1 },
{ "dr2", NULL, db_dr2 },
@@ -96,7 +93,6 @@
{ "dr5", NULL, db_dr5 },
{ "dr6", NULL, db_dr6 },
{ "dr7", NULL, db_dr7 },
-#endif
};
struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
@@ -124,12 +120,10 @@
struct proc *p, struct amd64_frame *frame, db_addr_t callpc);
-#if 0
static char * watchtype_str(int type);
int amd64_set_watch(int watchnum, unsigned int watchaddr, int size, int access,
struct dbreg * d);
int amd64_clr_watch(int watchnum, struct dbreg * d);
-#endif
int db_md_set_watchpoint(db_expr_t addr, db_expr_t size);
int db_md_clr_watchpoint(db_expr_t addr, db_expr_t size);
void db_md_list_watchpoints(void);
@@ -517,7 +511,6 @@
db_stack_trace_cmd(ebp, 1, -1, NULL);
}
-#if 0
#define DB_DRX_FUNC(reg) \
int \
db_ ## reg (vp, valuep, op) \
@@ -709,9 +702,9 @@
unsigned type, len;
type = (d.dr[7] >> (16+(i*4))) & 3;
len = (d.dr[7] >> (16+(i*4)+2)) & 3;
- db_printf(" %-5d %-8s %10s %3d 0x%08x\n",
+ db_printf(" %-5d %-8s %10s %3d 0x%016lx\n",
i, "enabled", watchtype_str(type),
- len+1, DBREG_DRX((&d),i));
+ len + 1, DBREG_DRX((&d), i));
}
else {
db_printf(" %-5d disabled\n", i);
@@ -720,30 +713,7 @@
db_printf("\ndebug register values:\n");
for (i=0; i<8; i++) {
- db_printf(" dr%d 0x%08x\n", i, DBREG_DRX((&d),i));
+ db_printf(" dr%d 0x%016lx\n", i, DBREG_DRX((&d), i));
}
db_printf("\n");
}
-
-#else
-int
-db_md_set_watchpoint(addr, size)
- db_expr_t addr;
- db_expr_t size;
-{
- return (-1);
-}
-
-int
-db_md_clr_watchpoint(addr, size)
- db_expr_t addr;
- db_expr_t size;
-{
- return (-1);
-}
-
-void
-db_md_list_watchpoints()
-{
-}
-#endif
==== //depot/projects/smpng/sys/amd64/amd64/fpu.c#4 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/fpu.c,v 1.147 2003/12/06 23:19:47 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/fpu.c,v 1.148 2004/01/28 23:55:58 peter Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -112,26 +112,17 @@
* Initialize floating point unit.
*/
void
-fpuinit()
+fpuinit(void)
{
register_t savecrit;
u_short control;
- /*
- * fpusave() initializes the fpu and sets fpcurthread = NULL
- */
savecrit = intr_disable();
- fpusave(&fpu_cleanstate); /* XXX borrow for now */
+ PCPU_SET(fpcurthread, 0);
stop_emulating();
- /* XXX fpusave() doesn't actually initialize the fpu in the SSE case. */
fninit();
control = __INITIAL_FPUCW__;
fldcw(&control);
- start_emulating();
- intr_restore(savecrit);
-
- savecrit = intr_disable();
- stop_emulating();
fxsave(&fpu_cleanstate);
start_emulating();
fpu_cleanstate_ready = 1;
@@ -147,8 +138,12 @@
register_t savecrit;
savecrit = intr_disable();
- if (curthread == PCPU_GET(fpcurthread))
- fpusave(&PCPU_GET(curpcb)->pcb_save);
+ if (curthread == PCPU_GET(fpcurthread)) {
+ stop_emulating();
+ fxsave(&PCPU_GET(curpcb)->pcb_save);
+ start_emulating();
+ PCPU_SET(fpcurthread, 0);
+ }
intr_restore(savecrit);
}
@@ -422,42 +417,14 @@
control = __INITIAL_FPUCW__;
fldcw(&control);
pcb->pcb_flags |= PCB_FPUINITDONE;
- } else {
- /*
- * The following frstor may cause a trap when the state
- * being restored has a pending error. The error will
- * appear to have been triggered by the current (fpu) user
- * instruction even when that instruction is a no-wait
- * instruction that should not trigger an error (e.g.,
- * instructions are broken the same as frstor, so our
- * treatment does not amplify the breakage.
- */
+ } else
fxrstor(&pcb->pcb_save);
- }
intr_restore(s);
return (1);
}
/*
- * Wrapper for fnsave instruction.
- *
- * fpusave() must be called with interrupts disabled, so that it clears
- * fpcurthread atomically with saving the state. We require callers to do the
- * disabling, since most callers need to disable interrupts anyway to call
- * fpusave() atomically with checking fpcurthread.
- */
-void
-fpusave(struct savefpu *addr)
-{
-
- stop_emulating();
- fxsave(addr);
- start_emulating();
- PCPU_SET(fpcurthread, NULL);
-}
-
-/*
* This should be called with interrupts disabled and only when the owning
* FPU thread is non-null.
*/
==== //depot/projects/smpng/sys/amd64/amd64/genassym.c#10 (text+ko) ====
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/genassym.c,v 1.151 2003/11/21 03:01:59 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/genassym.c,v 1.152 2004/01/28 23:57:02 peter Exp $");
#include "opt_compat.h"
#include "opt_kstack_pages.h"
@@ -135,6 +135,13 @@
ASSYM(PCB_ES, offsetof(struct pcb, pcb_es));
ASSYM(PCB_FS, offsetof(struct pcb, pcb_fs));
ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
+ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
+ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
+ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
+ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
+ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
+ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
+ASSYM(PCB_DBREGS, PCB_DBREGS);
ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
ASSYM(PCB_FULLCTX, PCB_FULLCTX);
@@ -206,10 +213,5 @@
ASSYM(KUC32SEL, GSEL(GUCODE32_SEL, SEL_UPL));
ASSYM(SEL_RPL_MASK, SEL_RPL_MASK);
-ASSYM(MSR_FSBASE, MSR_FSBASE);
-ASSYM(MSR_GSBASE, MSR_GSBASE);
-ASSYM(MSR_KGSBASE, MSR_KGSBASE);
-ASSYM(GPROC0_SEL, GPROC0_SEL);
-
ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock));
ASSYM(MTX_RECURSECNT, offsetof(struct mtx, mtx_recurse));
==== //depot/projects/smpng/sys/amd64/amd64/local_apic.c#3 (text+ko) ====
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/local_apic.c,v 1.5 2003/12/06 23:14:44 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/local_apic.c,v 1.7 2004/01/30 00:24:45 peter Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -600,6 +600,10 @@
if (retval != 0)
printf("%s: Failed to setup the local APIC: returned %d\n",
best_enum->apic_name, retval);
+#ifdef SMP
+ /* Last, setup the cpu topology now that we have probed CPUs */
+ mp_topology();
+#endif
}
SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_FIRST, apic_setup_local, NULL)
@@ -634,7 +638,6 @@
* private the sys/i386 code. The public interface for the rest of the
* kernel is defined in mp_machdep.c.
*/
-#define DETECT_DEADLOCK
int
lapic_ipi_wait(int delay)
==== //depot/projects/smpng/sys/amd64/amd64/machdep.c#20 (text+ko) ====
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.602 2004/01/03 02:02:24 davidxu Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.603 2004/01/29 00:07:29 peter Exp $");
#include "opt_atalk.h"
#include "opt_atpic.h"
@@ -147,7 +147,7 @@
long Maxmem = 0;
-vm_paddr_t phys_avail[10];
+vm_paddr_t phys_avail[20];
/* must be 2 less so 0 0 can signal end of chunks */
#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(vm_offset_t)) - 2)
@@ -266,7 +266,7 @@
} else
sp = (char *)regs->tf_rsp - sizeof(struct sigframe) - 128;
/* Align to 16 bytes. */
- sfp = (struct sigframe *)((unsigned long)sp & ~0xF);
+ sfp = (struct sigframe *)((unsigned long)sp & ~0xFul);
/* Translate the signal if appropriate. */
if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize)
@@ -527,13 +527,35 @@
bzero((char *)regs, sizeof(struct trapframe));
regs->tf_rip = entry;
- regs->tf_rsp = ((stack - 8) & ~0xF) + 8;
+ regs->tf_rsp = ((stack - 8) & ~0xFul) + 8;
regs->tf_rdi = stack; /* argv */
regs->tf_rflags = PSL_USER | (regs->tf_rflags & PSL_T);
regs->tf_ss = _udatasel;
regs->tf_cs = _ucodesel;
/*
+ * Reset the hardware debug registers if they were in use.
+ * They won't have any meaning for the newly exec'd process.
+ */
+ if (pcb->pcb_flags & PCB_DBREGS) {
+ pcb->pcb_dr0 = 0;
+ pcb->pcb_dr1 = 0;
+ pcb->pcb_dr2 = 0;
+ pcb->pcb_dr3 = 0;
+ pcb->pcb_dr6 = 0;
+ pcb->pcb_dr7 = 0;
+ if (pcb == PCPU_GET(curpcb)) {
+ /*
+ * Clear the debug registers on the running
+ * CPU, otherwise they will end up affecting
+ * the next process we switch to.
+ */
+ reset_dbregs();
+ }
+ pcb->pcb_flags &= ~PCB_DBREGS;
+ }
+
+ /*
* Arrange to trap the next fpu or `fwait' instruction (see fpu.c
* for why fwait must be trapped at least if there is an fpu or an
* emulator). This is mainly to handle the case where npx0 is not
@@ -819,7 +841,8 @@
* "Consumer may safely assume that size value precedes data."
* ie: an int32_t immediately precedes smap.
*/
- smapbase = (struct bios_smap *)preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_SMAP);
+ smapbase = (struct bios_smap *)preload_search_info(kmdp,
+ MODINFO_METADATA | MODINFOMD_SMAP);
if (smapbase == NULL)
panic("No BIOS smap info from loader!");
@@ -983,30 +1006,26 @@
* Test for alternating 1's and 0's
*/
*(volatile int *)ptr = 0xaaaaaaaa;
- if (*(volatile int *)ptr != 0xaaaaaaaa) {
+ if (*(volatile int *)ptr != 0xaaaaaaaa)
page_bad = TRUE;
- }
/*
* Test for alternating 0's and 1's
*/
*(volatile int *)ptr = 0x55555555;
- if (*(volatile int *)ptr != 0x55555555) {
- page_bad = TRUE;
- }
+ if (*(volatile int *)ptr != 0x55555555)
+ page_bad = TRUE;
/*
* Test for all 1's
*/
*(volatile int *)ptr = 0xffffffff;
- if (*(volatile int *)ptr != 0xffffffff) {
+ if (*(volatile int *)ptr != 0xffffffff)
page_bad = TRUE;
- }
/*
* Test for all 0's
*/
*(volatile int *)ptr = 0x0;
- if (*(volatile int *)ptr != 0x0) {
+ if (*(volatile int *)ptr != 0x0)
page_bad = TRUE;
- }
/*
* Restore original value.
*/
@@ -1015,9 +1034,8 @@
/*
* Adjust array of valid/good pages.
*/
- if (page_bad == TRUE) {
+ if (page_bad == TRUE)
continue;
- }
/*
* If this good page is a continuation of the
* previous set of good pages, then just increase
@@ -1040,7 +1058,7 @@
break;
}
phys_avail[pa_indx++] = pa; /* start */
- phys_avail[pa_indx] = pa + PAGE_SIZE; /* end */
+ phys_avail[pa_indx] = pa + PAGE_SIZE; /* end */
}
physmem++;
}
@@ -1127,7 +1145,8 @@
if (x != GPROC0_SEL && x != (GPROC0_SEL + 1))
ssdtosd(&gdt_segs[x], &gdt[x]);
}
- ssdtosyssd(&gdt_segs[GPROC0_SEL], (struct system_segment_descriptor *)&gdt[GPROC0_SEL]);
+ ssdtosyssd(&gdt_segs[GPROC0_SEL],
+ (struct system_segment_descriptor *)&gdt[GPROC0_SEL]);
r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
r_gdt.rd_base = (long) gdt;
@@ -1136,7 +1155,7 @@
wrmsr(MSR_FSBASE, 0); /* User value */
wrmsr(MSR_GSBASE, (u_int64_t)pc);
- wrmsr(MSR_KGSBASE, 0); /* User value while we're in the kernel */
+ wrmsr(MSR_KGSBASE, 0); /* User value while in the kernel */
pcpu_init(pc, 0, sizeof(struct pcpu));
PCPU_SET(prvspace, pc);
@@ -1204,7 +1223,7 @@
common_tss[0].tss_rsp0 = thread0.td_kstack + \
KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb);
/* Ensure the stack is aligned to 16 bytes */
- common_tss[0].tss_rsp0 &= ~0xF;
+ common_tss[0].tss_rsp0 &= ~0xFul;
PCPU_SET(rsp0, common_tss[0].tss_rsp0);
/* doublefault stack space, runs on ist1 */
@@ -1559,17 +1578,197 @@
int
fill_dbregs(struct thread *td, struct dbreg *dbregs)
{
+ struct pcb *pcb;
+ if (td == NULL) {
+ dbregs->dr[0] = rdr0();
+ dbregs->dr[1] = rdr1();
+ dbregs->dr[2] = rdr2();
+ dbregs->dr[3] = rdr3();
+ dbregs->dr[6] = rdr6();
+ dbregs->dr[7] = rdr7();
+ } else {
+ pcb = td->td_pcb;
+ dbregs->dr[0] = pcb->pcb_dr0;
+ dbregs->dr[1] = pcb->pcb_dr1;
+ dbregs->dr[2] = pcb->pcb_dr2;
+ dbregs->dr[3] = pcb->pcb_dr3;
+ dbregs->dr[6] = pcb->pcb_dr6;
+ dbregs->dr[7] = pcb->pcb_dr7;
+ }
+ dbregs->dr[4] = 0;
+ dbregs->dr[5] = 0;
+ dbregs->dr[8] = 0;
+ dbregs->dr[9] = 0;
+ dbregs->dr[10] = 0;
+ dbregs->dr[11] = 0;
+ dbregs->dr[12] = 0;
+ dbregs->dr[13] = 0;
+ dbregs->dr[14] = 0;
+ dbregs->dr[15] = 0;
return (0);
}
int
set_dbregs(struct thread *td, struct dbreg *dbregs)
{
+ struct pcb *pcb;
+ int i;
+ u_int64_t mask1, mask2;
+
+ if (td == NULL) {
+ load_dr0(dbregs->dr[0]);
+ load_dr1(dbregs->dr[1]);
+ load_dr2(dbregs->dr[2]);
+ load_dr3(dbregs->dr[3]);
+ load_dr6(dbregs->dr[6]);
+ load_dr7(dbregs->dr[7]);
+ } else {
+ /*
+ * Don't let an illegal value for dr7 get set. Specifically,
+ * check for undefined settings. Setting these bit patterns
+ * result in undefined behaviour and can lead to an unexpected
+ * TRCTRAP or a general protection fault right here.
+ */
+ for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8;
+ i++, mask1 <<= 2, mask2 <<= 2)
+ if ((dbregs->dr[7] & mask1) == mask2)
+ return (EINVAL);
+
+ pcb = td->td_pcb;
+ /*
+ * Don't let a process set a breakpoint that is not within the
+ * process's address space. If a process could do this, it
+ * could halt the system by setting a breakpoint in the kernel
+ * (if ddb was enabled). Thus, we need to check to make sure
+ * that no breakpoints are being enabled for addresses outside
+ * process's address space, unless, perhaps, we were called by
+ * uid 0.
+ *
+ * XXX - what about when the watched area of the user's
+ * address space is written into from within the kernel
+ * ... wouldn't that still cause a breakpoint to be generated
+ * from within kernel mode?
+ */
+
+ if (suser(td) != 0) {
+ if (dbregs->dr[7] & 0x3) {
+ /* dr0 is enabled */
+ if (dbregs->dr[0] >= VM_MAXUSER_ADDRESS)
+ return (EINVAL);
+ }
+ if (dbregs->dr[7] & 0x3<<2) {
+ /* dr1 is enabled */
+ if (dbregs->dr[1] >= VM_MAXUSER_ADDRESS)
+ return (EINVAL);
+ }
+ if (dbregs->dr[7] & 0x3<<4) {
+ /* dr2 is enabled */
+ if (dbregs->dr[2] >= VM_MAXUSER_ADDRESS)
+ return (EINVAL);
+ }
+ if (dbregs->dr[7] & 0x3<<6) {
+ /* dr3 is enabled */
+ if (dbregs->dr[3] >= VM_MAXUSER_ADDRESS)
+ return (EINVAL);
+ }
+ }
+
+ pcb->pcb_dr0 = dbregs->dr[0];
+ pcb->pcb_dr1 = dbregs->dr[1];
+ pcb->pcb_dr2 = dbregs->dr[2];
+ pcb->pcb_dr3 = dbregs->dr[3];
+ pcb->pcb_dr6 = dbregs->dr[6];
+ pcb->pcb_dr7 = dbregs->dr[7];
+
+ pcb->pcb_flags |= PCB_DBREGS;
+ }
+
return (0);
}
+void
+reset_dbregs(void)
+{
+
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list