PERFORCE change 125046 for review
Rafal Jaworowski
raj at FreeBSD.org
Sat Aug 11 04:05:03 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=125046
Change 125046 by raj at raj_booke_intgr on 2007/08/11 11:04:06
Fix e500 kernel build
- adapt to gcc 4 requirements (initialize vars, add protos etc.)
- adapt to API changes in 7.0
- add pmap_remove_write(), pmap_enter_object
- rework pmap_enter(), pmap_enter_locked()
- rework sendsig(), syscall()
- eliminate unused code
Affected files ...
.. //depot/projects/e500/sys/dev/quicc/quicc_core.c#2 edit
.. //depot/projects/e500/sys/dev/scc/scc_bfe_quicc.c#2 edit
.. //depot/projects/e500/sys/dev/tsec/if_tsec.c#2 edit
.. //depot/projects/e500/sys/dev/tsec/if_tsecreg.h#2 edit
.. //depot/projects/e500/sys/dev/usb/usb_subr.c#2 edit
.. //depot/projects/e500/sys/kern/kern_sig.c#5 edit
.. //depot/projects/e500/sys/kern/tty.c#3 edit
.. //depot/projects/e500/sys/net/bpf.c#2 edit
.. //depot/projects/e500/sys/netinet/in.c#3 edit
.. //depot/projects/e500/sys/powerpc/booke/clock.c#2 edit
.. //depot/projects/e500/sys/powerpc/booke/copyinout.c#2 edit
.. //depot/projects/e500/sys/powerpc/booke/interrupt.c#2 edit
.. //depot/projects/e500/sys/powerpc/booke/locore.S#2 edit
.. //depot/projects/e500/sys/powerpc/booke/machdep.c#2 edit
.. //depot/projects/e500/sys/powerpc/booke/pmap.c#2 edit
.. //depot/projects/e500/sys/powerpc/booke/trap.c#2 edit
.. //depot/projects/e500/sys/powerpc/booke/trap_subr.S#2 edit
.. //depot/projects/e500/sys/powerpc/booke/uio_machdep.c#2 edit
.. //depot/projects/e500/sys/powerpc/booke/vm_machdep.c#2 edit
.. //depot/projects/e500/sys/powerpc/mpc85xx/ocpbus.c#2 edit
.. //depot/projects/e500/sys/powerpc/mpc85xx/pci_ocp.c#2 edit
.. //depot/projects/e500/sys/rpc/rpcclnt.c#2 edit
.. //depot/projects/e500/sys/vm/vm_fault.c#5 edit
.. //depot/projects/e500/sys/vm/vm_mmap.c#4 edit
.. //depot/projects/e500/sys/vm/vm_page.c#5 edit
Differences ...
==== //depot/projects/e500/sys/dev/quicc/quicc_core.c#2 (text+ko) ====
@@ -124,11 +124,11 @@
if (sc->sc_ires != NULL) {
error = bus_setup_intr(dev, sc->sc_ires,
- INTR_TYPE_TTY | INTR_FAST, quicc_bfe_intr, sc,
+ INTR_TYPE_TTY | INTR_FAST, NULL, quicc_bfe_intr, sc,
&sc->sc_icookie);
if (error) {
error = bus_setup_intr(dev, sc->sc_ires,
- INTR_TYPE_TTY | INTR_MPSAFE, quicc_bfe_intr, sc,
+ INTR_TYPE_TTY | INTR_MPSAFE, NULL, quicc_bfe_intr, sc,
&sc->sc_icookie);
} else
sc->sc_fastintr = 1;
@@ -348,7 +348,7 @@
sc->sc_fastintr = 0;
bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
bus_setup_intr(dev, sc->sc_ires, INTR_TYPE_TTY | INTR_MPSAFE,
- quicc_bfe_intr, sc, &sc->sc_icookie);
+ NULL, quicc_bfe_intr, sc, &sc->sc_icookie);
}
qd = device_get_ivars(child);
==== //depot/projects/e500/sys/dev/scc/scc_bfe_quicc.c#2 (text+ko) ====
@@ -66,7 +66,7 @@
sc->sc_class = &scc_quicc_class;
if (BUS_READ_IVAR(parent, dev, QUICC_IVAR_BRGCLK, &rclk))
rclk = 0;
- return (scc_bfe_probe(dev, 0, rclk));
+ return (scc_bfe_probe(dev, 0, rclk, 0));
}
static device_method_t scc_quicc_methods[] = {
==== //depot/projects/e500/sys/dev/tsec/if_tsec.c#2 (text+ko) ====
@@ -1119,7 +1119,7 @@
return (ENXIO);
}
error = bus_setup_intr(dev, *ires, INTR_TYPE_NET | INTR_MPSAFE,
- handler, sc, ihand);
+ NULL, handler, sc, ihand);
if (error) {
device_printf(dev, "failed to set up %s IRQ\n", iname);
if (bus_release_resource(dev, SYS_RES_IRQ, *irid, *ires))
==== //depot/projects/e500/sys/dev/tsec/if_tsecreg.h#2 (text+ko) ====
@@ -349,7 +349,3 @@
#define TSEC_RXBUFFER_ALIGNMENT 64
#define TSEC_DEFAULT_MAX_RX_BUFFER_SIZE 0x0600
#define TSEC_DEFAULT_MIN_RX_BUFFER_SIZE 0x0040
-
-#if (TSEC_DEFAULT_RX_BUFFER_SIZE > MCLBYTES)
-#error TSEC_DEFAULT_RX_BUFFER_SIZE > MCLBYTES !
-#endif
==== //depot/projects/e500/sys/dev/usb/usb_subr.c#2 (text+ko) ====
@@ -849,6 +849,7 @@
uaa.vendor = UGETW(dd->idVendor);
uaa.product = UGETW(dd->idProduct);
uaa.release = UGETW(dd->bcdDevice);
+ uaa.matchlvl = 0;
/* First try with device specific drivers. */
DPRINTF(("usbd_probe_and_attach: trying device specific drivers\n"));
==== //depot/projects/e500/sys/kern/kern_sig.c#5 (text+ko) ====
@@ -1174,6 +1174,8 @@
p = td->td_proc;
error = 0;
sig = 0;
+ ets.tv_sec = 0;
+ ets.tv_nsec = 0;
SIG_CANTMASK(waitset);
PROC_LOCK(p);
==== //depot/projects/e500/sys/kern/tty.c#3 (text+ko) ====
@@ -1720,7 +1720,7 @@
int s, first, error = 0;
int has_stime = 0, last_cc = 0;
long slp = 0; /* XXX this should be renamed `timo'. */
- struct timeval stime;
+ struct timeval stime = { 0, 0 };
struct pgrp *pg;
td = curthread;
==== //depot/projects/e500/sys/net/bpf.c#2 (text+ko) ====
@@ -614,6 +614,8 @@
return (0);
bzero(&dst, sizeof(dst));
+ m = NULL;
+ hlen = 0;
error = bpf_movein(uio, (int)d->bd_bif->bif_dlt, ifp->if_mtu,
&m, &dst, &hlen, d->bd_wfilter);
if (error)
==== //depot/projects/e500/sys/netinet/in.c#3 (text+ko) ====
@@ -622,6 +622,7 @@
int cmp;
bzero(&mask, sizeof(mask));
+ bzero(&match, sizeof(match));
if (iflr->flags & IFLR_PREFIX) {
/* lookup a prefix rather than address. */
in_len2mask(&mask, iflr->prefixlen);
@@ -822,9 +823,10 @@
struct in_addr prefix, mask, p, m;
int error;
- if ((flags & RTF_HOST) != 0)
+ if ((flags & RTF_HOST) != 0) {
prefix = target->ia_dstaddr.sin_addr;
- else {
+ mask.s_addr = 0;
+ } else {
prefix = target->ia_addr.sin_addr;
mask = target->ia_sockmask.sin_addr;
prefix.s_addr &= mask.s_addr;
==== //depot/projects/e500/sys/powerpc/booke/clock.c#2 (text+ko) ====
@@ -63,6 +63,7 @@
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/bus.h>
+#include <sys/clock.h>
#include <sys/timetc.h>
#include <sys/interrupt.h>
@@ -81,17 +82,6 @@
static u_long ticks_per_sec = 12500000;
static long ticks_per_intr;
-static int sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ARGS);
-
-int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
-SYSCTL_INT(_machdep, CPU_WALLCLOCK, wall_cmos_clock,
- CTLFLAG_RW, &wall_cmos_clock, 0, "");
-
-int adjkerntz; /* local offset from GMT in seconds */
-SYSCTL_PROC(_machdep, CPU_ADJKERNTZ, adjkerntz, CTLTYPE_INT|CTLFLAG_RW,
- &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", "");
-
-#define SECDAY 86400
#define DIFF19041970 2082844800
static int clockinitted = 0;
@@ -105,17 +95,6 @@
"decrementer" /* name */
};
-static int
-sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ARGS)
-{
- int error;
-
- error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
- if (!error && req->newptr)
- resettodr();
- return (error);
-}
-
void
inittodr(time_t base)
{
@@ -160,7 +139,7 @@
}
void
-decr_intr(struct clockframe *frame)
+decr_intr(struct trapframe *frame)
{
u_long msr;
@@ -182,7 +161,7 @@
msr = mfmsr();
mtmsr(msr | PSL_EE);
- hardclock(frame);
+ hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
}
void
==== //depot/projects/e500/sys/powerpc/booke/copyinout.c#2 (text+ko) ====
@@ -269,14 +269,20 @@
return ((int32_t)fuword(addr));
}
-intptr_t
-casuptr(intptr_t *addr, intptr_t old, intptr_t new)
+uint32_t
+casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval)
+{
+ return (casuword((volatile u_long *)base, oldval, newval));
+}
+
+u_long
+casuword(volatile u_long *addr, u_long old, u_long new)
{
struct thread *td;
faultbuf env;
- intptr_t val;
+ u_long val;
- if (!is_uaddr(addr))
+ if (!((vm_offset_t)addr <= VM_MAXUSER_ADDRESS))
return (EFAULT);
td = PCPU_GET(curthread);
@@ -287,7 +293,7 @@
}
val = *addr;
- (void) atomic_cmpset_32(addr, old, new);
+ (void) atomic_cmpset_32((volatile uint32_t *)addr, old, new);
td->td_pcb->pcb_onfault = NULL;
==== //depot/projects/e500/sys/powerpc/booke/interrupt.c#2 (text+ko) ====
@@ -58,7 +58,7 @@
#include <machine/trap.h>
#include <machine/interruptvar.h>
-extern void decr_intr(struct clockframe *);
+extern void decr_intr(struct trapframe *);
extern void trap(struct trapframe *);
void powerpc_decr_interrupt(struct trapframe *);
@@ -120,14 +120,11 @@
void
powerpc_decr_interrupt(struct trapframe *framep)
{
- struct clockframe ckframe;
struct thread *td;
td = PCPU_GET(curthread);
atomic_add_int(&td->td_intr_nesting_level, 1);
- ckframe.srr0 = framep->srr0;
- ckframe.srr1 = framep->srr1;
- decr_intr(&ckframe);
+ decr_intr(framep);
atomic_subtract_int(&td->td_intr_nesting_level, 1);
}
@@ -156,7 +153,7 @@
#ifdef INTR_DEBUG
-/* temporary handler for development purposes - DELETEME LATER */
+/* XXX temporary handler for development purposes - DELETEME LATER */
void
unserviced_intr(struct trapframe *framep)
{
==== //depot/projects/e500/sys/powerpc/booke/locore.S#2 (text+ko) ====
@@ -491,4 +491,4 @@
.space INTRCNT_COUNT * 4 * 2
GLOBAL(eintrcnt)
-#include <powerpc/e500/trap_subr.S>
+#include <powerpc/booke/trap_subr.S>
==== //depot/projects/e500/sys/powerpc/booke/machdep.c#2 (text+ko) ====
@@ -181,6 +181,13 @@
void dump_bootinfo(void);
void dump_kenv(void);
void e500_init(u_int32_t, u_int32_t, void *);
+void setPQL2(int *const size, int *const ways);
+
+void
+setPQL2(int *const size, int *const ways)
+{
+ return;
+}
static void
cpu_e500_startup(void *dummy)
@@ -353,7 +360,7 @@
init_param1();
/* Start initializing proc0 and thread0. */
- proc_linkup(&proc0, &ksegrp0, &thread0);
+ proc_linkup(&proc0, &thread0);
thread0.td_frame = &frame0;
/* Set up per-cpu data and store the pointer in SPR general 0. */
@@ -574,6 +581,7 @@
return (0);
}
+#if 0
/* Build siginfo_t for SA thread. */
void
cpu_thread_siginfo(int sig, u_long code, siginfo_t *si)
@@ -590,6 +598,7 @@
si->si_code = code;
/* XXXKSE fill other fields */
}
+#endif
int
sigreturn(struct thread *td, struct sigreturn_args *uap)
@@ -762,7 +771,7 @@
}
void
-sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
+sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
{
struct trapframe *tf;
struct sigframe *sfp;
@@ -771,10 +780,13 @@
struct thread *td;
struct proc *p;
int oonstack, rndfsize;
+ int sig, code;
td = curthread;
p = td->td_proc;
PROC_LOCK_ASSERT(p, MA_OWNED);
+ sig = ksi->ksi_signo;
+ code = ksi->ksi_code;
psp = p->p_sigacts;
mtx_assert(&psp->ps_mtx, MA_OWNED);
tf = td->td_frame;
@@ -842,12 +854,15 @@
/*
* Fill siginfo structure.
*/
+ sf.sf_si = ksi->ksi_info;
sf.sf_si.si_signo = sig;
- sf.sf_si.si_code = code;
- sf.sf_si.si_addr = (void *)tf->srr0;
+ sf.sf_si.si_addr = (void *) ((tf->exc == EXC_DSI) ?
+ tf->dear : tf->srr0);
} else {
/* Old FreeBSD-style arguments. */
tf->fixreg[FIRSTARG+1] = code;
+ tf->fixreg[FIRSTARG+3] = (tf->exc == EXC_DSI) ?
+ tf->dear : tf->srr0;
}
mtx_unlock(&psp->ps_mtx);
PROC_UNLOCK(p);
@@ -909,3 +924,12 @@
len--;
}
}
+
+/*
+ * XXX what is the better/proper place for this routine?
+ */
+int
+mem_valid(vm_offset_t addr, int len)
+{
+ return (1);
+}
==== //depot/projects/e500/sys/powerpc/booke/pmap.c#2 (text+ko) ====
@@ -130,6 +130,8 @@
/* PMAP */
/**************************************************************************/
+static void pmap_enter_locked(pmap_t, vm_offset_t, vm_page_t, vm_prot_t, boolean_t);
+
/* Kernel pmap */
struct pmap kernel_pmap_store;
@@ -1041,17 +1043,12 @@
* Extract the physical page address associated with the given
* kernel virtual address.
*/
-__inline vm_paddr_t
+vm_paddr_t
pmap_kextract(vm_offset_t va)
{
return pte_vatopa(kernel_pmap, va);
}
-void
-pmap_init2(void)
-{
-}
-
/*
* Initialize the pmap module.
* Called by vm_init, to initialize any structures that the pmap
@@ -1289,7 +1286,19 @@
* will be wired down.
*/
void
-pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, boolean_t wired)
+pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
+ boolean_t wired)
+{
+ vm_page_lock_queues();
+ PMAP_LOCK(pmap);
+ pmap_enter_locked(pmap, va, m, prot, wired);
+ vm_page_unlock_queues();
+ PMAP_UNLOCK(pmap);
+}
+
+static void
+pmap_enter_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
+ boolean_t wired)
{
pte_t *pte;
vm_paddr_t pa;
@@ -1300,21 +1309,20 @@
su = (pmap == kernel_pmap);
sync = 0;
- //debugf("pmap_enter: s (pmap=0x%08x su=%d tid=%d m=0x%08x va=0x%08x "
+ //debugf("pmap_enter_locked: s (pmap=0x%08x su=%d tid=%d m=0x%08x va=0x%08x "
// "pa=0x%08x prot=0x%08x wired=%d)\n",
// (u_int32_t)pmap, su, pmap->pm_tid,
// (u_int32_t)m, va, pa, prot, wired);
if (su) {
KASSERT(((va >= virtual_avail) && (va <= VM_MAX_KERNEL_ADDRESS)),
- ("pmap_enter: kernel pmap, non kernel va"));
+ ("pmap_enter_locked: kernel pmap, non kernel va"));
} else {
KASSERT((va <= VM_MAXUSER_ADDRESS),
- ("pmap_enter: user pmap, non user va"));
+ ("pmap_enter_locked: user pmap, non user va"));
}
- vm_page_lock_queues();
- PMAP_LOCK(pmap);
+ PMAP_LOCK_ASSERT(pmap, MA_OWNED);
/*
* If there is an existing mapping, and the physical address has not
@@ -1323,7 +1331,7 @@
if (((pte = pte_find(pmap, va)) != NULL) &&
(PTE_ISVALID(pte)) && (PTE_PA(pte) == pa)) {
- //debugf("pmap_enter: update\n");
+ //debugf("pmap_enter_locked: update\n");
/* Wiring change, just update stats. */
if (wired) {
@@ -1375,9 +1383,9 @@
* physical address, pte_enter() will delete the old mapping.
*/
//if ((pte != NULL) && PTE_ISVALID(pte))
- // debugf("pmap_enter: replace\n");
+ // debugf("pmap_enter_locked: replace\n");
//else
- // debugf("pmap_enter: new\n");
+ // debugf("pmap_enter_locked: new\n");
/* Now set up the flags and install the new mapping. */
flags = (PTE_SR | PTE_VALID);
@@ -1415,12 +1423,9 @@
sync = 0;
}
- PMAP_UNLOCK(pmap);
-
if (sync) {
/* Create a temporary mapping. */
pmap = PCPU_GET(curpmap);
- PMAP_LOCK(pmap);
va = 0;
pte = pte_find(pmap, va);
@@ -1430,20 +1435,48 @@
pte_enter(pmap, m, va, flags);
__syncicache((void *)va, PAGE_SIZE);
pte_remove(pmap, va, PTBL_UNHOLD);
- PMAP_UNLOCK(pmap);
}
- vm_page_unlock_queues();
+ //debugf("pmap_enter_locked: e\n");
+}
+
+/*
+ * Maps a sequence of resident pages belonging to the same object.
+ * The sequence begins with the given page m_start. This page is
+ * mapped at the given virtual address start. Each subsequent page is
+ * mapped at a virtual address that is offset from start by the same
+ * amount as the page is offset from m_start within the object. The
+ * last page in the sequence is the page with the largest offset from
+ * m_start that can be mapped at a virtual address less than the given
+ * virtual address end. Not every virtual page between start and end
+ * is mapped; only those for which a resident page exists with the
+ * corresponding offset from m_start are mapped.
+ */
+void
+pmap_enter_object(pmap_t pmap, vm_offset_t start, vm_offset_t end, vm_page_t m_start,
+ vm_prot_t prot)
+{
+ vm_page_t m;
+ vm_pindex_t diff, psize;
- //debugf("pmap_enter: e\n");
+ psize = atop(end - start);
+ m = m_start;
+ PMAP_LOCK(pmap);
+ while (m != NULL && (diff = m->pindex - m_start->pindex) < psize) {
+ pmap_enter_locked(pmap, start + ptoa(diff), m, prot &
+ (VM_PROT_READ | VM_PROT_EXECUTE), FALSE);
+ m = TAILQ_NEXT(m, listq);
+ }
+ PMAP_UNLOCK(pmap);
}
-vm_page_t
-pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
- vm_page_t mpte)
+void
+pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot)
{
//debugf("pmap_enter_quick: s\n");
+#if 0
+ /* XXX this is the old way - test if the new approach is really ok..? */
vm_page_busy(m);
vm_page_unlock_queues();
VM_OBJECT_UNLOCK(m->object);
@@ -1451,9 +1484,14 @@
VM_OBJECT_LOCK(m->object);
vm_page_lock_queues();
vm_page_wakeup(m);
+#endif
+ PMAP_LOCK(pmap);
+ pmap_enter_locked(pmap, va, m, prot & (VM_PROT_READ | VM_PROT_EXECUTE),
+ FALSE);
+ PMAP_UNLOCK(pmap);
+
//debugf("pmap_enter_quick e\n");
- return (NULL);
}
/*
@@ -1668,6 +1706,7 @@
vm_page_unlock_queues();
}
+#if 0
/*
* Lower the permission for all mappings to a given page.
*/
@@ -1715,7 +1754,45 @@
}
vm_page_flag_clear(m, PG_WRITEABLE);
}
+#endif
+
+void
+pmap_remove_write(vm_page_t m)
+{
+ pv_entry_t pv;
+ pte_t *pte;
+ mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+ if ((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) != 0 ||
+ (m->flags & PG_WRITEABLE) == 0)
+ return;
+
+ TAILQ_FOREACH(pv, &m->md.pv_list, pv_link) {
+ PMAP_LOCK(pv->pv_pmap);
+ if ((pte = pte_find(pv->pv_pmap, pv->pv_va)) != NULL) {
+ if (PTE_ISVALID(pte)) {
+ m = PHYS_TO_VM_PAGE(PTE_PA(pte));
+
+ /* Handle modified pages. */
+ if (PTE_ISMODIFIED(pte)) {
+ if (pmap_track_modified(pv->pv_pmap, pv->pv_va))
+ vm_page_dirty(m);
+ }
+
+ /* Referenced pages. */
+ if (PTE_ISREFERENCED(pte))
+ vm_page_flag_set(m, PG_REFERENCED);
+
+ /* Flush mapping from TLB0. */
+ pte->flags &= ~(PTE_UW | PTE_SW | PTE_MODIFIED | PTE_REFERENCED);
+ tlb0_flush_entry(pv->pv_pmap, pv->pv_va);
+ }
+ }
+ PMAP_UNLOCK(pv->pv_pmap);
+ }
+ vm_page_flag_clear(m, PG_WRITEABLE);
+}
+
boolean_t
pmap_page_executable(vm_page_t m)
{
@@ -1851,7 +1928,7 @@
* an entire address space. Only works for the current pmap.
*/
void
-pmap_remove_pages(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
+pmap_remove_pages(pmap_t pmap)
{
}
@@ -2883,7 +2960,7 @@
return (EINVAL);
/*
- * The BAT entry must be cache-inhibited, guarded, and r/w
+ * The entry must be cache-inhibited, guarded, and r/w
* so it can function as an i/o page
*/
prot = tlb1[i].mas2 & (MAS2_I | MAS2_G);
==== //depot/projects/e500/sys/powerpc/booke/trap.c#2 (text+ko) ====
@@ -43,6 +43,7 @@
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/pioctl.h>
+#include <sys/ptrace.h>
#include <sys/reboot.h>
#include <sys/syscall.h>
#include <sys/sysent.h>
@@ -54,6 +55,8 @@
#endif
#include <sys/vmmeter.h>
+#include <security/audit/audit.h>
+
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
@@ -136,9 +139,9 @@
struct thread *td;
struct proc *p;
int sig, type, user;
- u_int sticks;
+ ksiginfo_t ksi;
- PCPU_LAZY_INC(cnt.v_trap);
+ PCPU_INC(cnt.v_trap);
td = PCPU_GET(curthread);
p = td->td_proc;
@@ -146,13 +149,11 @@
type = frame->exc;
sig = 0;
user = (frame->srr1 & PSL_PR) ? 1 : 0;
- sticks = 0;
CTR3(KTR_TRAP, "trap: %s type=%s (%s)", p->p_comm,
trapname(type), user ? "user" : "kernel");
if (user) {
- sticks = td->td_sticks;
td->td_frame = frame;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -221,10 +222,15 @@
if (sig != 0) {
if (p->p_sysent->sv_transtrap != NULL)
sig = (p->p_sysent->sv_transtrap)(sig, type);
- trapsignal(td, sig, type);
+ ksiginfo_init_trap(&ksi);
+ ksi.ksi_signo = sig;
+ ksi.ksi_code = type; /* XXX, not POSIX */
+ /* ksi.ksi_addr = ? */
+ ksi.ksi_trapno = type;
+ trapsignal(td, &ksi);
}
- userret(td, frame, sticks);
+ userret(td, frame);
mtx_assert(&Giant, MA_NOTOWNED);
}
@@ -316,10 +322,12 @@
td = PCPU_GET(curthread);
p = td->td_proc;
- PCPU_LAZY_INC(cnt.v_syscall);
+ PCPU_INC(cnt.v_syscall);
+#if KSE
if (p->p_flag & P_SA)
thread_user_enter(td);
+#endif
code = frame->fixreg[0];
params = (caddr_t)(frame->fixreg + FIRSTARG);
@@ -358,7 +366,7 @@
else
callp = &p->p_sysent->sv_table[code];
- narg = callp->sy_narg & SYF_ARGMASK;
+ narg = callp->sy_narg;
if (narg > n) {
bcopy(params, args, n * sizeof(register_t));
@@ -378,11 +386,8 @@
if (KTRPOINT(td, KTR_SYSCALL))
ktrsyscall(code, narg, (register_t *)params);
#endif
- /*
- * Try to run the syscall without Giant if the syscall is MP safe.
- */
- if ((callp->sy_narg & SYF_MPSAFE) == 0)
- mtx_lock(&Giant);
+
+ td->td_syscalls++;
if (error == 0) {
td->td_retval[0] = 0;
@@ -390,7 +395,11 @@
STOPEVENT(p, S_SCE, narg);
+ PTRACESTOP_SC(p, td, S_PT_SCE);
+
+ AUDIT_SYSCALL_ENTER(code, td);
error = (*callp->sy_call)(td, params);
+ AUDIT_SYSCALL_EXIT(error, td);
CTR3(KTR_SYSC, "syscall: p=%s %s ret=%x", p->p_comm,
syscallnames[code], td->td_retval[0]);
@@ -398,8 +407,7 @@
switch (error) {
case 0:
- if ((frame->fixreg[0] == SYS___syscall) &&
- (code != SYS_lseek)) {
+ if (frame->fixreg[0] == SYS___syscall && SYS_lseek) {
/*
* 64-bit return, 32-bit syscall. Fixup byte order
*/
@@ -434,9 +442,18 @@
break;
}
-
- if ((callp->sy_narg & SYF_MPSAFE) == 0)
- mtx_unlock(&Giant);
+ /*
+ * Check for misbehavior.
+ */
+ WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???");
+ KASSERT(td->td_critnest == 0,
+ ("System call %s returning in a critical section",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"));
+ KASSERT(td->td_locks == 0,
+ ("System call %s returning with %d locks held",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???",
+ td->td_locks));
#ifdef KTRACE
if (KTRPOINT(td, KTR_SYSRET))
@@ -448,10 +465,7 @@
*/
STOPEVENT(p, S_SCX, code);
- WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
- (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???");
- mtx_assert(&sched_lock, MA_NOTOWNED);
- mtx_assert(&Giant, MA_NOTOWNED);
+ PTRACESTOP_SC(p, td, S_PT_SCX);
}
static int
==== //depot/projects/e500/sys/powerpc/booke/trap_subr.S#2 (text+ko) ====
@@ -783,6 +783,8 @@
addi %r3, %r1, 8
bl CNAME(ast)
+ .globl CNAME(asttrapexit) /* db_backtrace code sentinel #2 */
+CNAME(asttrapexit):
b trapexit /* test ast ret value ? */
1:
FRAME_LEAVE(SPR_SRR0, SPR_SRR1)
==== //depot/projects/e500/sys/powerpc/booke/uio_machdep.c#2 (text+ko) ====
@@ -52,6 +52,7 @@
#include <machine/cpu.h>
#include <machine/vmparam.h>
+#include <machine/md_var.h>
/*
* Implement uiomove(9) from physical memory using sf_bufs to
==== //depot/projects/e500/sys/powerpc/booke/vm_machdep.c#2 (text+ko) ====
@@ -247,7 +247,7 @@
void
cpu_throw(struct thread *old, struct thread *new)
{
- cpu_switch(old, new);
+ cpu_switch(old, new, NULL);
panic("cpu_throw() didn't");
}
==== //depot/projects/e500/sys/powerpc/mpc85xx/ocpbus.c#2 (text+ko) ====
@@ -48,6 +48,8 @@
#include "pic_if.h"
+extern struct bus_space bs_be_tag;
+
struct ocpbus_softc {
struct rman sc_mem;
device_t sc_pic;
@@ -345,7 +347,7 @@
{
const struct ocp_resource *res;
struct ocp_devinfo *dinfo;
- u_long start, count;
+ u_long start = 0, count = 0;
int error;
dinfo = device_get_ivars(child);
@@ -531,7 +533,7 @@
struct ocpbus_softc *sc;
sc = device_get_softc(dev);
- return (openpic_setup_intr(sc->sc_pic, child, res, flags, intr, arg,
+ return (openpic_setup_intr(sc->sc_pic, child, res, flags, NULL, intr, arg,
cookiep));
}
==== //depot/projects/e500/sys/powerpc/mpc85xx/pci_ocp.c#2 (text+ko) ====
@@ -144,6 +144,8 @@
sizeof(struct pci_ocp_softc),
};
+devclass_t pcib_devclass;
+
DRIVER_MODULE(pcib, ocpbus, pci_ocp_driver, pcib_devclass, 0, 0);
static uint32_t
==== //depot/projects/e500/sys/rpc/rpcclnt.c#2 (text+ko) ====
@@ -1182,6 +1182,19 @@
cred);
/*
+ * This can happen if the auth_type is neither UNIX or NULL
+ */
+ if (m == NULL) {
+#ifdef __OpenBSD__
+ pool_put(&rpctask_pool, task);
+#else
+ FREE(task, M_RPC);
+#endif
+ error = EPROTONOSUPPORT;
+ goto rpcmout;
+ }
+
+ /*
* For stream protocols, insert a Sun RPC Record Mark.
*/
if (rpc->rc_sotype == SOCK_STREAM) {
@@ -1867,6 +1880,7 @@
*tl++ = txdr_unsigned(procid);
if ((error = rpcauth_buildheader(rc->rc_auth, cred, &mb, &bpos))) {
+ m_freem(mreq);
RPCDEBUG("rpcauth_buildheader failed %d", error);
return NULL;
}
==== //depot/projects/e500/sys/vm/vm_fault.c#5 (text+ko) ====
@@ -464,7 +464,7 @@
*/
if (TRYPAGER) {
int rv;
- int reqpage;
+ int reqpage = 0;
int ahead, behind;
u_char behavior = vm_map_entry_behavior(fs.entry);
==== //depot/projects/e500/sys/vm/vm_mmap.c#4 (text+ko) ====
@@ -1291,7 +1291,7 @@
vm_ooffset_t foff)
{
boolean_t fitit;
- vm_object_t object;
+ vm_object_t object = NULL;
int rv = KERN_SUCCESS;
int docow, error;
struct thread *td = curthread;
==== //depot/projects/e500/sys/vm/vm_page.c#5 (text+ko) ====
@@ -1506,7 +1506,7 @@
*
* Inputs are required to range within a page.
*/
-inline int
+int
vm_page_bits(int base, int size)
{
int first_bit;
More information about the p4-projects
mailing list