svn commit: r224056 - in head/sys: kern sys

2011-07-15 Thread Jonathan Anderson
Author: jonathan
Date: Fri Jul 15 09:37:14 2011
New Revision: 224056
URL: http://svn.freebsd.org/changeset/base/224056

Log:
  Add implementation for capabilities.
  
  Code to actually implement Capsicum capabilities, including fileops and
  kern_capwrap(), which creates a capability to wrap an existing file
  descriptor.
  
  We also modify kern_close() and closef() to handle capabilities.
  
  Finally, remove cap_filelist from struct capability, since we don't
  actually need it.
  
  Approved by: mentor (rwatson), re (Capsicum blanket)
  Sponsored by: Google Inc

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/kern/sys_capability.c
  head/sys/sys/capability.h

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Jul 15 06:54:21 2011
(r224055)
+++ head/sys/kern/kern_descrip.cFri Jul 15 09:37:14 2011
(r224056)
@@ -1160,7 +1160,7 @@ kern_close(td, fd)
int fd;
 {
struct filedesc *fdp;
-   struct file *fp;
+   struct file *fp, *fp_object;
int error;
int holdleaders;
 
@@ -1195,8 +1195,14 @@ kern_close(td, fd)
 * added, and deleteing a knote for the new fd.
 */
knote_fdclose(td, fd);
-   if (fp->f_type == DTYPE_MQUEUE)
-   mq_fdclose(td, fd, fp);
+
+   /*
+* When we're closing an fd with a capability, we need to notify
+* mqueue if the underlying object is of type mqueue.
+*/
+   (void)cap_funwrap(fp, 0, &fp_object);
+   if (fp_object->f_type == DTYPE_MQUEUE)
+   mq_fdclose(td, fd, fp_object);
FILEDESC_XUNLOCK(fdp);
 
error = closef(fp, td);
@@ -2146,6 +2152,7 @@ closef(struct file *fp, struct thread *t
struct flock lf;
struct filedesc_to_leader *fdtol;
struct filedesc *fdp;
+   struct file *fp_object;
 
/*
 * POSIX record locking dictates that any close releases ALL
@@ -2158,11 +2165,15 @@ closef(struct file *fp, struct thread *t
 * NULL thread pointer when there really is no owning
 * context that might have locks, or the locks will be
 * leaked.
+*
+* If this is a capability, we do lock processing under the underlying
+* node, not the capability itself.
 */
-   if (fp->f_type == DTYPE_VNODE && td != NULL) {
+   (void)cap_funwrap(fp, 0, &fp_object);
+   if ((fp_object->f_type == DTYPE_VNODE) && (td != NULL)) {
int vfslocked;
 
-   vp = fp->f_vnode;
+   vp = fp_object->f_vnode;
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
if ((td->td_proc->p_leader->p_flag & P_ADVLOCK) != 0) {
lf.l_whence = SEEK_SET;
@@ -2192,7 +2203,7 @@ closef(struct file *fp, struct thread *t
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_UNLCK;
-   vp = fp->f_vnode;
+   vp = fp_object->f_vnode;
(void) VOP_ADVLOCK(vp,
   (caddr_t)fdtol->fdl_leader,
   F_UNLCK, &lf, F_POSIX);
@@ -2497,6 +2508,9 @@ fputsock(struct socket *so)
 
 /*
  * Handle the last reference to a file being closed.
+ *
+ * No special capability handling here, as the capability's fo_close will run
+ * instead of the object here, and perform any necessary drop on the object.
  */
 int
 _fdrop(struct file *fp, struct thread *td)

Modified: head/sys/kern/sys_capability.c
==
--- head/sys/kern/sys_capability.c  Fri Jul 15 06:54:21 2011
(r224055)
+++ head/sys/kern/sys_capability.c  Fri Jul 15 09:37:14 2011
(r224056)
@@ -123,18 +123,66 @@ cap_getmode(struct thread *td, struct ca
  * struct capability describes a capability, and is hung off of its struct
  * file f_data field.  cap_file and cap_rightss are static once hooked up, as
  * neither the object it references nor the rights it encapsulates are
- * permitted to change.  cap_filelist may change when other capabilites are
- * added or removed from the same file, and is currently protected by the
- * pool mutex for the object file descriptor.
+ * permitted to change.
  */
 struct capability {
struct file *cap_object;/* Underlying object's file. */
struct file *cap_file;  /* Back-pointer to cap's file. */
cap_rights_t cap_rights;/* Mask of rights on object. */
-   LIST_ENTRY(capability)  cap_filelist; /* Object's cap list. */
 };
 
 /*
+ * Capabilities have a fileops vector, but in practice none should ever be
+ * called except for fo_close, as the capability will normally not be
+ * returned during a file descriptor lookup in t

svn commit: r224057 - in head/usr.sbin: pmccontrol pmcstat

2011-07-15 Thread Andriy Gapon
Author: avg
Date: Fri Jul 15 11:30:41 2011
New Revision: 224057
URL: http://svn.freebsd.org/changeset/base/224057

Log:
  pmcstat, pmccontrol: catch up with removal of machdep.hlt_cpus sysctl
  
  Reported by:  Pan Tsu 
  Reviewed by:  attilio
  No objections:gnn

Modified:
  head/usr.sbin/pmccontrol/pmccontrol.c
  head/usr.sbin/pmcstat/pmcstat.c

Modified: head/usr.sbin/pmccontrol/pmccontrol.c
==
--- head/usr.sbin/pmccontrol/pmccontrol.c   Fri Jul 15 09:37:14 2011
(r224056)
+++ head/usr.sbin/pmccontrol/pmccontrol.c   Fri Jul 15 11:30:41 2011
(r224057)
@@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -134,33 +133,15 @@ pmcc_init_debug(void)
 static int
 pmcc_do_enable_disable(struct pmcc_op_list *op_list)
 {
-   long cpusetsize;
int c, error, i, j, ncpu, npmc, t;
-   cpuset_t haltedcpus, cpumask;
struct pmcc_op *np;
unsigned char *map;
unsigned char op;
int cpu, pmc;
-   size_t setsize;
 
if ((ncpu = pmc_ncpu()) < 0)
err(EX_OSERR, "Unable to determine the number of cpus");
 
-   /* Determine the set of active CPUs. */
-   cpusetsize = sysconf(_SC_CPUSET_SIZE);
-   if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) {
-   err(EX_OSERR, "ERROR: Cannot determine which CPUs are "
-   "halted");
-   }
-   CPU_ZERO(&haltedcpus);
-   setsize = (size_t)cpusetsize;
-   if (ncpu > 1 && sysctlbyname("machdep.hlt_cpus", &haltedcpus,
-   &setsize, NULL, 0) < 0)
-   err(EX_OSERR, "ERROR: Cannot determine which CPUs are "
-   "halted");
-   CPU_FILL(&cpumask);
-   CPU_NAND(&cpumask, &haltedcpus);
-
/* Determine the maximum number of PMCs in any CPU. */
npmc = 0;
for (c = 0; c < ncpu; c++) {
@@ -207,8 +188,7 @@ pmcc_do_enable_disable(struct pmcc_op_li
 
if (cpu == PMCC_CPU_ALL)
for (i = 0; i < ncpu; i++) {
-   if (CPU_ISSET(i, &cpumask))
-   SET_PMCS(i, pmc, op);
+   SET_PMCS(i, pmc, op);
}
else
SET_PMCS(cpu, pmc, op);

Modified: head/usr.sbin/pmcstat/pmcstat.c
==
--- head/usr.sbin/pmcstat/pmcstat.c Fri Jul 15 09:37:14 2011
(r224056)
+++ head/usr.sbin/pmcstat/pmcstat.c Fri Jul 15 11:30:41 2011
(r224057)
@@ -552,7 +552,7 @@ int
 main(int argc, char **argv)
 {
double interval;
-   int option, npmc, ncpu, haltedcpus;
+   int option, npmc, ncpu;
int c, check_driver_stats, current_cpu, current_sampling_count;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
int do_print;
@@ -617,14 +617,6 @@ main(int argc, char **argv)
if (sysctlbyname("hw.ncpu", &ncpu, &dummy, NULL, 0) < 0)
err(EX_OSERR, "ERROR: Cannot determine the number of CPUs");
cpumask = (1 << ncpu) - 1;
-   haltedcpus = 0;
-   if (ncpu > 1) {
-   if (sysctlbyname("machdep.hlt_cpus", &haltedcpus, &dummy,
-   NULL, 0) < 0)
-   err(EX_OSERR, "ERROR: Cannot determine which CPUs are "
-   "halted");
-   cpumask &= ~haltedcpus;
-   }
 
while ((option = getopt(argc, argv,
"CD:EF:G:M:NO:P:R:S:TWc:df:gk:m:n:o:p:qr:s:t:vw:z:")) != -1)
@@ -637,7 +629,7 @@ main(int argc, char **argv)
case 'c':   /* CPU */
 
if (optarg[0] == '*' && optarg[1] == '\0')
-   cpumask = ((1 << ncpu) - 1) & ~haltedcpus;
+   cpumask = (1 << ncpu) - 1;
else
cpumask = pmcstat_get_cpumask(optarg);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r224058 - head/usr.sbin/pmccontrol

2011-07-15 Thread Attilio Rao
Author: attilio
Date: Fri Jul 15 11:46:54 2011
New Revision: 224058
URL: http://svn.freebsd.org/changeset/base/224058

Log:
  Fix logical_cpus_mask retrieving by using, correctly, cpuset_t.
  This fix also a bug where pmccontrol uses a 32 static type rather than
  old cpumask_t.
  
  Reported and reviewed by: avg

Modified:
  head/usr.sbin/pmccontrol/pmccontrol.c

Modified: head/usr.sbin/pmccontrol/pmccontrol.c
==
--- head/usr.sbin/pmccontrol/pmccontrol.c   Fri Jul 15 11:30:41 2011
(r224057)
+++ head/usr.sbin/pmccontrol/pmccontrol.c   Fri Jul 15 11:46:54 2011
(r224058)
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -220,9 +221,10 @@ pmcc_do_enable_disable(struct pmcc_op_li
 static int
 pmcc_do_list_state(void)
 {
-   size_t dummy;
+   cpuset_t logical_cpus_mask;
+   long cpusetsize;
+   size_t setsize;
int c, cpu, n, npmc, ncpu;
-   unsigned int logical_cpus_mask;
struct pmc_info *pd;
struct pmc_pmcinfo *pi;
const struct pmc_cpuinfo *pc;
@@ -234,17 +236,22 @@ pmcc_do_list_state(void)
   pmc_name_of_cputype(pc->pm_cputype),
pc->pm_npmc);
 
-   dummy = sizeof(logical_cpus_mask);
+   /* Determine the set of logical CPUs. */
+   cpusetsize = sysconf(_SC_CPUSET_SIZE);
+   if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t))
+   err(EX_OSERR, "Cannot determine which CPUs are logical");
+   CPU_ZERO(&logical_cpus_mask);
+   setsize = (size_t)cpusetsize;
if (sysctlbyname("machdep.logical_cpus_mask", &logical_cpus_mask,
-   &dummy, NULL, 0) < 0)
-   logical_cpus_mask = 0;
+   &setsize, NULL, 0) < 0)
+   CPU_ZERO(&logical_cpus_mask);
 
ncpu = pc->pm_ncpu;
 
for (c = cpu = 0; cpu < ncpu; cpu++) {
 #ifdefined(__i386__) || defined(__amd64__)
if (pc->pm_cputype == PMC_CPU_INTEL_PIV &&
-   (logical_cpus_mask & (1 << cpu)))
+   CPU_ISSET(cpu, &logical_cpus_mask))
continue; /* skip P4-style 'logical' cpus */
 #endif
if (pmc_pmcinfo(cpu, &pi) < 0) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r224048 - head/etc/rc.d

2011-07-15 Thread Jilles Tjoelker
On Fri, Jul 15, 2011 at 01:59:09AM +, Kevin Lo wrote:
> Author: kevlo
> Date: Fri Jul 15 01:59:08 2011
> New Revision: 224048
> URL: http://svn.freebsd.org/changeset/base/224048

> Log:
>   Remove "-n" from echo

>   Reviewed by:dougb

> Modified:
>   head/etc/rc.d/routing

> Modified: head/etc/rc.d/routing
> ==
> --- head/etc/rc.d/routing Fri Jul 15 01:50:40 2011(r224047)
> +++ head/etc/rc.d/routing Fri Jul 15 01:59:08 2011(r224048)
> @@ -287,7 +287,7 @@ options_inet()
>  
>   if checkyesno gateway_enable; then
>   ropts_init
> - echo -n ' IPv4 gateway=YES'
> + echo ' IPv4 gateway=YES'
>   ${SYSCTL} net.inet.ip.forwarding=1 > /dev/null
>   else
>   ${SYSCTL} net.inet.ip.forwarding=0 > /dev/null
> @@ -322,7 +322,7 @@ options_inet6()
>  {
>   if checkyesno ipv6_gateway_enable; then
>   ropts_init
> - echo -n ' IPv6 gateway=YES'
> + echo ' IPv6 gateway=YES'
>   ${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null
>   else
>   ${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null

It looks like this has been added because some IPv6 code is printing
stuff about routes for :::0.0.0.0, ::0.0.0.0, fe80:: and ff02::,
which often gets in between things on the "Additional routing options:"
line, leading to ugly output.

However, it is inconsistent to change this for the gateway options only
and not for the other options and makes output uglier unnecessarily in
the !IPv6 case.

Perhaps it is best to use a separate line for each af, finishing it
within the options_$af function.

-- 
Jilles Tjoelker
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r224059 - head/sbin/fsck_ffs

2011-07-15 Thread Kirk McKusick
Author: mckusick
Date: Fri Jul 15 15:43:40 2011
New Revision: 224059
URL: http://svn.freebsd.org/changeset/base/224059

Log:
  Break out the pass 5 inode and block map updating into a separate function
  so that the function can be used by the journaling soft updates recovery.

Modified:
  head/sbin/fsck_ffs/fsck.h
  head/sbin/fsck_ffs/pass5.c

Modified: head/sbin/fsck_ffs/fsck.h
==
--- head/sbin/fsck_ffs/fsck.h   Fri Jul 15 11:46:54 2011(r224058)
+++ head/sbin/fsck_ffs/fsck.h   Fri Jul 15 15:43:40 2011(r224059)
@@ -395,5 +395,6 @@ voidsetinodebuf(ino_t);
 intsetup(char *dev);
 void   gjournal_check(const char *filesys);
 intsuj_check(const char *filesys);
+void   update_maps(struct cg *, struct cg*, int);
 
 #endif /* !_FSCK_H_ */

Modified: head/sbin/fsck_ffs/pass5.c
==
--- head/sbin/fsck_ffs/pass5.c  Fri Jul 15 11:46:54 2011(r224058)
+++ head/sbin/fsck_ffs/pass5.c  Fri Jul 15 15:43:40 2011(r224059)
@@ -49,8 +49,8 @@ __FBSDID("$FreeBSD$");
 
 #include "fsck.h"
 
-static void check_maps(u_char *, u_char *, int, ufs2_daddr_t, const char *, 
int *, int, int);
-
+static void check_maps(u_char *, u_char *, int, ufs2_daddr_t, const char *,
+   int *, int, int, int);
 static void clear_blocks(ufs2_daddr_t start, ufs2_daddr_t end);
 
 void
@@ -61,7 +61,7 @@ pass5(void)
struct fs *fs = &sblock;
struct cg *cg = &cgrp;
ufs2_daddr_t d, dbase, dmax, start;
-   int excessdirs, rewritecg = 0;
+   int rewritecg = 0;
struct csum *cs;
struct csum_total cstotal;
struct inodesc idesc[3];
@@ -333,27 +333,8 @@ pass5(void)
memmove(cg, newcg, (size_t)basesize);
cgdirty();
}
-   if (bkgrdflag != 0 || usedsoftdep || debug) {
-   excessdirs = cg->cg_cs.cs_ndir - newcg->cg_cs.cs_ndir;
-   if (excessdirs < 0) {
-   pfatal("LOST %d DIRECTORIES\n", -excessdirs);
-   excessdirs = 0;
-   }
-   if (excessdirs > 0)
-   check_maps(cg_inosused(newcg), cg_inosused(cg),
-   inomapsize,
-   cg->cg_cgx * (ufs2_daddr_t) fs->fs_ipg,
-   "DIR",
-   freedirs, 0, excessdirs);
-   check_maps(cg_inosused(newcg), cg_inosused(cg),
-   inomapsize,
-   cg->cg_cgx * (ufs2_daddr_t) fs->fs_ipg, "FILE",
-   freefiles, excessdirs, fs->fs_ipg);
-   check_maps(cg_blksfree(cg), cg_blksfree(newcg),
-   blkmapsize,
-   cg->cg_cgx * (ufs2_daddr_t) fs->fs_fpg, "FRAG",
-   freeblks, 0, fs->fs_fpg);
-   }
+   if (bkgrdflag != 0 || usedsoftdep || debug)
+   update_maps(cg, newcg, bkgrdflag);
if (cursnapshot == 0 &&
memcmp(cg_inosused(newcg), cg_inosused(cg), mapsize) != 0 &&
dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
@@ -426,6 +407,40 @@ pass5(void)
}
 }
 
+/*
+ * Compare the original cylinder group inode and block bitmaps with the
+ * updated cylinder group inode and block bitmaps. Free inodes and blocks
+ * that have been added. Complain if any previously freed inodes blocks
+ * are now allocated.
+ */
+void
+update_maps(
+   struct cg *oldcg,   /* cylinder group of claimed allocations */
+   struct cg *newcg,   /* cylinder group of determined allocations */
+   int usesysctl)  /* 1 => use sysctl interface to update maps */
+{
+   int inomapsize, excessdirs;
+   struct fs *fs = &sblock;
+
+   inomapsize = howmany(fs->fs_ipg, CHAR_BIT);
+   excessdirs = oldcg->cg_cs.cs_ndir - newcg->cg_cs.cs_ndir;
+   if (excessdirs < 0) {
+   pfatal("LOST %d DIRECTORIES\n", -excessdirs);
+   excessdirs = 0;
+   }
+   if (excessdirs > 0)
+   check_maps(cg_inosused(newcg), cg_inosused(oldcg), inomapsize,
+   oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_ipg, "DIR", freedirs,
+   0, excessdirs, usesysctl);
+   check_maps(cg_inosused(newcg), cg_inosused(oldcg), inomapsize,
+   oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_ipg, "FILE", freefiles,
+   excessdirs, fs->fs_ipg, usesysctl);
+   check_maps(cg_blksfree(oldcg), cg_blksfree(newcg),
+   howmany(fs->fs_fpg, CHAR_BIT),
+   oldcg->cg_cgx * (ufs2_daddr_t)fs->fs_fpg, "FRAG",
+   freeblks, 0, fs->fs_fpg, usesysctl);
+}
+
 s

svn commit: r224060 - head/share/man/man4

2011-07-15 Thread Glen Barber
Author: gjb (doc committer)
Date: Fri Jul 15 15:56:23 2011
New Revision: 224060
URL: http://svn.freebsd.org/changeset/base/224060

Log:
  Remove an extra '.It' from axe(4).
  
  Reported by:  manlint

Modified:
  head/share/man/man4/axe.4

Modified: head/share/man/man4/axe.4
==
--- head/share/man/man4/axe.4   Fri Jul 15 15:43:40 2011(r224059)
+++ head/share/man/man4/axe.4   Fri Jul 15 15:56:23 2011(r224060)
@@ -222,7 +222,6 @@ AX88760:
 .It
 ASIX AX88760
 .El
-.It
 .Sh DIAGNOSTICS
 .Bl -diag
 .It "axe%d: watchdog timeout"
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r224061 - in head/sys/ufs: ffs ufs

2011-07-15 Thread Kirk McKusick
Author: mckusick
Date: Fri Jul 15 16:20:33 2011
New Revision: 224061
URL: http://svn.freebsd.org/changeset/base/224061

Log:
  Add an FFS specific mount option to allow a filesystem checker
  (typically fsck_ffs) to register that it wishes to use FFS specific
  sysctl's to update the filesystem. This ensures that two checkers
  cannot run on a given filesystem at the same time and that no other
  process accidentally or maliciously uses the filesystem updating
  sysctls inappropriately. This functionality is needed by the
  journaling soft-updates recovery code.

Modified:
  head/sys/ufs/ffs/ffs_alloc.c
  head/sys/ufs/ffs/ffs_inode.c
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ffs/fs.h
  head/sys/ufs/ufs/ufsmount.h

Modified: head/sys/ufs/ffs/ffs_alloc.c
==
--- head/sys/ufs/ffs/ffs_alloc.cFri Jul 15 15:56:23 2011
(r224060)
+++ head/sys/ufs/ffs/ffs_alloc.cFri Jul 15 16:20:33 2011
(r224061)
@@ -2381,6 +2381,18 @@ ffs_fserr(fs, inum, cp)
  * in the current directory is oldvalue then change it to newvalue.
  * unlink(nameptr, oldvalue) - Verify that the inode number associated
  * with nameptr in the current directory is oldvalue then unlink it.
+ *
+ * The following functions may only be used on a quiescent filesystem
+ * by the soft updates journal. They are not safe to be run on an active
+ * filesystem.
+ *
+ * setinode(inode, dip) - the specified disk inode is replaced with the
+ * contents pointed to by dip.
+ * setbufoutput(fd, flags) - output associated with the specified file
+ * descriptor (which must reference the character device supporting
+ * the filesystem) switches from using physio to running through the
+ * buffer cache when flags is set to 1. The descriptor reverts to
+ * physio for output when flags is set to zero.
  */
 
 static int sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS);
@@ -2427,11 +2439,21 @@ static SYSCTL_NODE(_vfs_ffs, FFS_SET_DOT
 static SYSCTL_NODE(_vfs_ffs, FFS_UNLINK, unlink, CTLFLAG_WR,
sysctl_ffs_fsck, "Unlink a Duplicate Name");
 
+static SYSCTL_NODE(_vfs_ffs, FFS_SET_INODE, setinode, CTLFLAG_WR,
+   sysctl_ffs_fsck, "Update an On-Disk Inode");
+
+static SYSCTL_NODE(_vfs_ffs, FFS_SET_BUFOUTPUT, setbufoutput, CTLFLAG_WR,
+   sysctl_ffs_fsck, "Set Buffered Writing for Descriptor");
+
+#define DEBUG 1
 #ifdef DEBUG
-static int fsckcmds = 0;
+static int fsckcmds = 1;
 SYSCTL_INT(_debug, OID_AUTO, fsckcmds, CTLFLAG_RW, &fsckcmds, 0, "");
 #endif /* DEBUG */
 
+static int buffered_write(struct file *, struct uio *, struct ucred *,
+   int, struct thread *);
+
 static int
 sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
 {
@@ -2445,8 +2467,10 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
ufs2_daddr_t blkno;
long blkcnt, blksize;
struct filedesc *fdp;
-   struct file *fp;
+   struct file *fp, *vfp;
int vfslocked, filetype, error;
+   static struct fileops *origops, bufferedops;
+   static int outcnt = 0;
 
if (req->newlen > sizeof cmd)
return (EBADRPC);
@@ -2454,7 +2478,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
return (error);
if (cmd.version != FFS_CMD_VERSION)
return (ERPCMISMATCH);
-   if ((error = getvnode(curproc->p_fd, cmd.handle, &fp)) != 0)
+   if ((error = getvnode(td->td_proc->p_fd, cmd.handle, &fp)) != 0)
return (error);
vp = fp->f_data;
if (vp->v_type != VREG && vp->v_type != VDIR) {
@@ -2467,12 +2491,13 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
fdrop(fp, td);
return (EINVAL);
}
-   if (mp->mnt_flag & MNT_RDONLY) {
+   ump = VFSTOUFS(mp);
+   if ((mp->mnt_flag & MNT_RDONLY) &&
+   ump->um_fsckpid != td->td_proc->p_pid) {
vn_finished_write(mp);
fdrop(fp, td);
return (EROFS);
}
-   ump = VFSTOUFS(mp);
fs = ump->um_fs;
filetype = IFREG;
 
@@ -2493,7 +2518,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
case FFS_ADJ_REFCNT:
 #ifdef DEBUG
if (fsckcmds) {
-   printf("%s: adjust inode %jd count by %jd\n",
+   printf("%s: adjust inode %jd link count by %jd\n",
mp->mnt_stat.f_mntonname, (intmax_t)cmd.value,
(intmax_t)cmd.size);
}
@@ -2504,7 +2529,8 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
ip->i_nlink += cmd.size;
DIP_SET(ip, i_nlink, ip->i_nlink);
ip->i_effnlink += cmd.size;
-   ip->i_flag |= IN_CHANGE;
+   ip->i_flag |= IN_CHANGE | IN_MODIFIED;
+   error = ffs_update(vp, 1);
if (DOINGSOFTDEP(vp))
softdep_change_linkcnt(ip);
vput(vp);
@@ -2522,7 +2548,8 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)

svn commit: r224062 - head/usr.bin/top

2011-07-15 Thread John Baldwin
Author: jhb
Date: Fri Jul 15 17:23:45 2011
New Revision: 224062
URL: http://svn.freebsd.org/changeset/base/224062

Log:
  Revert 130163 and let top use KERN_PROC_PROC when individual threads are
  not displayed.  The KERN_PROC_PROC sysctl was fixed in 188764.

Modified:
  head/usr.bin/top/machine.c

Modified: head/usr.bin/top/machine.c
==
--- head/usr.bin/top/machine.c  Fri Jul 15 16:20:33 2011(r224061)
+++ head/usr.bin/top/machine.c  Fri Jul 15 17:23:45 2011(r224062)
@@ -624,7 +624,6 @@ get_process_info(struct system_info *si,
int active_procs;
struct kinfo_proc **prefp;
struct kinfo_proc *pp;
-   struct kinfo_proc *prev_pp = NULL;
 
/* these are copied out of sel for speed */
int show_idle;
@@ -657,7 +656,8 @@ get_process_info(struct system_info *si,
}
previous_proc_count = nproc;
 
-   pbase = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nproc);
+   pbase = kvm_getprocs(kd, sel->thread ? KERN_PROC_ALL : KERN_PROC_PROC,
+   0, &nproc);
if (nproc > onproc)
pref = realloc(pref, sizeof(*pref) * (onproc = nproc));
if (pref == NULL || pbase == NULL) {
@@ -727,21 +727,8 @@ get_process_info(struct system_info *si,
/* skip proc. that don't belong to the selected UID */
continue;
 
-   /*
-* When not showing threads, take the first thread
-* for output and add the fields that we can from
-* the rest of the process's threads rather than
-* using the system's mostly-broken KERN_PROC_PROC.
-*/
-   if (sel->thread || prev_pp == NULL ||
-   prev_pp->ki_pid != pp->ki_pid) {
-   *prefp++ = pp;
-   active_procs++;
-   prev_pp = pp;
-   } else {
-   prev_pp->ki_pctcpu += pp->ki_pctcpu;
-   prev_pp->ki_runtime += pp->ki_runtime;
-   }
+   *prefp++ = pp;
+   active_procs++;
}
 
/* if requested, sort the "interesting" processes */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r224063 - head/sys/i386

2011-07-15 Thread Kirk McKusick
Author: mckusick
Date: Fri Jul 15 17:27:26 2011
New Revision: 224063
URL: http://svn.freebsd.org/changeset/base/224063

Log:
  Delete duplicate tags entry I introduced in -r223901.
  
  Submitted-by: John Baldwin

Modified:
  head/sys/i386/Makefile

Modified: head/sys/i386/Makefile
==
--- head/sys/i386/Makefile  Fri Jul 15 17:23:45 2011(r224062)
+++ head/sys/i386/Makefile  Fri Jul 15 17:27:26 2011(r224063)
@@ -25,10 +25,9 @@ links::
(cd $$i && { rm -f tags; ln -s ../tags tags; }) done
 
 SI386= ${SYS}/i386/acpica/*.[ch] ${SYS}/i386/bios/*.[ch] \
-   ${SYS}/i386/pci/*.[ch] ${SYS}/i386/pci/*.[ch] \
${SYS}/i386/i386/*.[ch] ${SYS}/i386/ibcs2/*.[ch] \
${SYS}/i386/include/*.[ch] ${SYS}/i386/isa/*.[ch] \
-   ${SYS}/i386/linux/*.[ch]
+   ${SYS}/i386/linux/*.[ch] ${SYS}/i386/pci/*.[ch]
 AI386= ${SYS}/i386/i386/*.s
 
 tags::
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r224066 - in head/sys: compat/freebsd32 kern sys

2011-07-15 Thread Jonathan Anderson
Author: jonathan
Date: Fri Jul 15 18:26:19 2011
New Revision: 224066
URL: http://svn.freebsd.org/changeset/base/224066

Log:
  Add cap_new() and cap_getrights() system calls.
  
  Implement two previously-reserved Capsicum system calls:
  - cap_new() creates a capability to wrap an existing file descriptor
  - cap_getrights() queries the rights mask of a capability.
  
  Approved by: mentor (rwatson), re (Capsicum blanket)
  Sponsored by: Google Inc

Modified:
  head/sys/compat/freebsd32/syscalls.master
  head/sys/kern/sys_capability.c
  head/sys/kern/syscalls.master
  head/sys/sys/capability.h

Modified: head/sys/compat/freebsd32/syscalls.master
==
--- head/sys/compat/freebsd32/syscalls.master   Fri Jul 15 18:10:59 2011
(r224065)
+++ head/sys/compat/freebsd32/syscalls.master   Fri Jul 15 18:26:19 2011
(r224066)
@@ -957,8 +957,9 @@
 512AUE_SHMCTL  NOSTD   { int freebsd32_shmctl(int shmid, int cmd, \
struct shmid_ds32 *buf); }
 513AUE_LPATHCONF   NOPROTO { int lpathconf(char *path, int name); }
-514AUE_CAP_NEW UNIMPL  cap_new
-515AUE_CAP_GETRIGHTS   UNIMPL  cap_getrights
+514AUE_CAP_NEW NOPROTO { int cap_new(int fd, u_int64_t rights); }
+515AUE_CAP_GETRIGHTS   NOPROTO { int cap_getrights(int fd, \
+   u_int64_t *rightsp); }
 516AUE_CAP_ENTER   NOPROTO { int cap_enter(void); }
 517AUE_CAP_GETMODE NOPROTO { int cap_getmode(u_int *modep); }
 518AUE_PDFORK  UNIMPL  pdfork

Modified: head/sys/kern/sys_capability.c
==
--- head/sys/kern/sys_capability.c  Fri Jul 15 18:10:59 2011
(r224065)
+++ head/sys/kern/sys_capability.c  Fri Jul 15 18:26:19 2011
(r224066)
@@ -212,6 +212,59 @@ cap_rights(struct file *fp_cap)
 }
 
 /*
+ * System call to create a new capability reference to either an existing
+ * file object or an an existing capability.
+ */
+int
+cap_new(struct thread *td, struct cap_new_args *uap)
+{
+   int error, capfd;
+   int fd = uap->fd;
+   struct file *fp, *fcapp;
+   cap_rights_t rights = uap->rights;
+
+   AUDIT_ARG_FD(fd);
+#ifdef notyet  /* capability auditing will follow in a few commits */
+   AUDIT_ARG_RIGHTS(rights);
+#endif
+   error = fget(td, fd, &fp);
+   if (error)
+   return (error);
+   AUDIT_ARG_FILE(td->td_proc, fp);
+   error = kern_capwrap(td, fp, rights, &fcapp, &capfd);
+   if (error)
+   return (error);
+
+   /*
+* Release our reference to the file (kern_capwrap has held a reference
+* for the filedesc array).
+*/
+   fdrop(fp, td);
+   td->td_retval[0] = capfd;
+   return (0);
+}
+
+/*
+ * System call to query the rights mask associated with a capability.
+ */
+int
+cap_getrights(struct thread *td, struct cap_getrights_args *uap)
+{
+   struct capability *cp;
+   struct file *fp;
+   int error;
+
+   AUDIT_ARG_FD(uap->fd);
+   error = fgetcap(td, uap->fd, &fp);
+   if (error)
+   return (error);
+   cp = fp->f_data;
+   error = copyout(&cp->cap_rights, uap->rightsp, sizeof(*uap->rightsp));
+   fdrop(fp, td);
+   return (error);
+}
+
+/*
  * Create a capability to wrap around an existing file.
  */
 int
@@ -423,6 +476,20 @@ capability_stat(struct file *fp, struct 
  * into the kernel.
  */
 int
+cap_new(struct thread *td, struct cap_new_args *uap)
+{
+
+   return (ENOSYS);
+}
+
+int
+cap_getrights(struct thread *td, struct cap_getrights_args *uap)
+{
+
+   return (ENOSYS);
+}
+
+int
 cap_funwrap(struct file *fp_cap, cap_rights_t rights, struct file **fpp)
 {
 

Modified: head/sys/kern/syscalls.master
==
--- head/sys/kern/syscalls.master   Fri Jul 15 18:10:59 2011
(r224065)
+++ head/sys/kern/syscalls.master   Fri Jul 15 18:26:19 2011
(r224066)
@@ -914,8 +914,9 @@
 512AUE_SHMCTL  NOSTD   { int shmctl(int shmid, int cmd, \
struct shmid_ds *buf); }
 513AUE_LPATHCONF   STD { int lpathconf(char *path, int name); }
-514AUE_CAP_NEW UNIMPL  cap_new
-515AUE_CAP_GETRIGHTS   UNIMPL  cap_getrights
+514AUE_CAP_NEW STD { int cap_new(int fd, u_int64_t rights); }
+515AUE_CAP_GETRIGHTS   STD { int cap_getrights(int fd, \
+   u_int64_t *rightsp); }
 516AUE_CAP_ENTER   STD { int cap_enter(void); }
 517AUE_CAP_GETMODE STD { int cap_getmode(u_int *modep); }
 518AUE_PDFORK  UNIMPL  pdfork

Modified: head/sys/sys/capability.h
==
--- head/sys/sys/capability.h   Fri Jul 15 18:10:59 2011(r224065)
+++ hea

svn commit: r224067 - in head/sys: compat/freebsd32 kern sys

2011-07-15 Thread Jonathan Anderson
Author: jonathan
Date: Fri Jul 15 18:33:12 2011
New Revision: 224067
URL: http://svn.freebsd.org/changeset/base/224067

Log:
  Auto-generated system call code with cap_new(), cap_getrights().
  
  Approved by: mentor (rwatson), re (Capsicum blanket)
  Sponsored by: Google Inc

Modified:
  head/sys/compat/freebsd32/freebsd32_proto.h
  head/sys/compat/freebsd32/freebsd32_syscall.h
  head/sys/compat/freebsd32/freebsd32_syscalls.c
  head/sys/compat/freebsd32/freebsd32_sysent.c
  head/sys/compat/freebsd32/freebsd32_systrace_args.c
  head/sys/kern/init_sysent.c
  head/sys/kern/syscalls.c
  head/sys/kern/systrace_args.c
  head/sys/sys/syscall.h
  head/sys/sys/syscall.mk
  head/sys/sys/sysproto.h

Modified: head/sys/compat/freebsd32/freebsd32_proto.h
==
--- head/sys/compat/freebsd32/freebsd32_proto.h Fri Jul 15 18:26:19 2011
(r224066)
+++ head/sys/compat/freebsd32/freebsd32_proto.h Fri Jul 15 18:33:12 2011
(r224067)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 223166 
2011-06-16 22:05:56Z kib 
+ * created from FreeBSD
  */
 
 #ifndef _FREEBSD32_SYSPROTO_H_

Modified: head/sys/compat/freebsd32/freebsd32_syscall.h
==
--- head/sys/compat/freebsd32/freebsd32_syscall.h   Fri Jul 15 18:26:19 
2011(r224066)
+++ head/sys/compat/freebsd32/freebsd32_syscall.h   Fri Jul 15 18:33:12 
2011(r224067)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 223166 
2011-06-16 22:05:56Z kib 
+ * created from FreeBSD
  */
 
 #defineFREEBSD32_SYS_syscall   0
@@ -411,6 +411,8 @@
 #defineFREEBSD32_SYS_freebsd32_msgctl  511
 #defineFREEBSD32_SYS_freebsd32_shmctl  512
 #defineFREEBSD32_SYS_lpathconf 513
+#defineFREEBSD32_SYS_cap_new   514
+#defineFREEBSD32_SYS_cap_getrights 515
 #defineFREEBSD32_SYS_cap_enter 516
 #defineFREEBSD32_SYS_cap_getmode   517
 #defineFREEBSD32_SYS_freebsd32_pselect 522

Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c
==
--- head/sys/compat/freebsd32/freebsd32_syscalls.c  Fri Jul 15 18:26:19 
2011(r224066)
+++ head/sys/compat/freebsd32/freebsd32_syscalls.c  Fri Jul 15 18:33:12 
2011(r224067)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 223166 
2011-06-16 22:05:56Z kib 
+ * created from FreeBSD
  */
 
 const char *freebsd32_syscallnames[] = {
@@ -537,8 +537,8 @@ const char *freebsd32_syscallnames[] = {
"freebsd32_msgctl", /* 511 = freebsd32_msgctl */
"freebsd32_shmctl", /* 512 = freebsd32_shmctl */
"lpathconf",/* 513 = lpathconf */
-   "#514", /* 514 = cap_new */
-   "#515", /* 515 = cap_getrights */
+   "cap_new",  /* 514 = cap_new */
+   "cap_getrights",/* 515 = cap_getrights */
"cap_enter",/* 516 = cap_enter */
"cap_getmode",  /* 517 = cap_getmode */
"#518", /* 518 = pdfork */

Modified: head/sys/compat/freebsd32/freebsd32_sysent.c
==
--- head/sys/compat/freebsd32/freebsd32_sysent.cFri Jul 15 18:26:19 
2011(r224066)
+++ head/sys/compat/freebsd32/freebsd32_sysent.cFri Jul 15 18:33:12 
2011(r224067)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 223166 
2011-06-16 22:05:56Z kib 
+ * created from FreeBSD
  */
 
 #include "opt_compat.h"
@@ -574,8 +574,8 @@ struct sysent freebsd32_sysent[] = {
{ AS(freebsd32_msgctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 
0, 0, SY_THR_ABSENT },  /* 511 = freebsd32_msgctl */
{ AS(freebsd32_shmctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 
0, 0, SY_THR_ABSENT },  /* 512 = freebsd32_shmctl */
{ AS(lpathconf_args), (sy_call_t *)lpathconf, AUE_LPATHCONF, NULL, 0, 
0, 0, SY_THR_STATIC },/* 513 = lpathconf */
-   { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },  
/* 514 = cap_new */
-   { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },  
/* 515 = cap_getrights */
+   { AS(cap_new_args), (sy_call_t *)cap_new, AUE_CAP_NEW, NULL, 0, 0, 0, 
SY_THR_STATIC },  /* 514 = cap_new */
+   { AS(cap_getrights_

svn commit: r224068 - head/sys/conf

2011-07-15 Thread Joel Dahl
Author: joel (doc committer)
Date: Fri Jul 15 19:02:44 2011
New Revision: 224068
URL: http://svn.freebsd.org/changeset/base/224068

Log:
  Sort snd_* entries alphabetically.

Modified:
  head/sys/conf/NOTES

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Fri Jul 15 18:33:12 2011(r224067)
+++ head/sys/conf/NOTES Fri Jul 15 19:02:44 2011(r224068)
@@ -2253,14 +2253,14 @@ device  sound
 #  conjunction with snd_sbc.
 # snd_sbc: Creative SoundBlaster ISA PnP/non-PnP.
 #  Supports ESS and Avance ISA chips as well.
-# snd_spicds:  SPI codec driver, needed by Envy24/Envy24HT drivers.
 # snd_solo:ESS Solo-1x PCI.
+# snd_spicds:  SPI codec driver, needed by Envy24/Envy24HT drivers.
 # snd_t4dwave: Trident 4DWave DX/NX PCI, Sis 7018 PCI and Acer Labs
 #  M5451 PCI.
+# snd_uaudio:  USB audio.
 # snd_via8233: VIA VT8233x PCI.
 # snd_via82c686:   VIA VT82C686A PCI.
 # snd_vibes:   S3 Sonicvibes PCI.
-# snd_uaudio:  USB audio.
 
 device snd_ad1816
 device snd_als4000
@@ -2290,10 +2290,10 @@ device  snd_sbc
 device snd_solo
 device snd_spicds
 device snd_t4dwave
+device snd_uaudio
 device snd_via8233
 device snd_via82c686
 device snd_vibes
-device snd_uaudio
 
 # For non-PnP sound cards:
 hint.pcm.0.at="isa"
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r223922 - head/usr.bin/rpcgen

2011-07-15 Thread Jilles Tjoelker
On Mon, Jul 11, 2011 at 05:31:53AM +, Xin LI wrote:
> Author: delphij
> Date: Mon Jul 11 05:31:52 2011
> New Revision: 223922
> URL: http://svn.freebsd.org/changeset/base/223922

> Log:
>   Use strlcpy().

>   MFC after:  1 month

It looks like the length is known in all four cases, so that memcpy()
can be used instead of strncpy() or strlcpy(), with explicitly assigning
a '\0' (like with the former strncpy()).

In particular, strlcpy()'s implicit strlen of the source operand is
wasteful here, particularly for input files with long lines. It also
adds a hidden dependency on *str being null-terminated, which is a bit
ugly even though it is satisfied and used elsewhere in the code.

> Modified:
>   head/usr.bin/rpcgen/rpc_scan.c

> Modified: head/usr.bin/rpcgen/rpc_scan.c
> ==
> --- head/usr.bin/rpcgen/rpc_scan.cMon Jul 11 05:22:31 2011
> (r223921)
> +++ head/usr.bin/rpcgen/rpc_scan.cMon Jul 11 05:31:52 2011
> (r223922)
> @@ -329,10 +329,9 @@ findstrconst(char **str, const char **va
>   error("unterminated string constant");
>   }
>   p++;
> - size = p - *str;
> - tmp = xmalloc(size + 1);
> - (void) strncpy(tmp, *str, size);
> - tmp[size] = 0;
> + size = p - *str + 1;
> + tmp = xmalloc(size);
> + (void) strlcpy(tmp, *str, size);
>   *val = tmp;
>   *str = p;
>  }
> @@ -352,13 +351,12 @@ findchrconst(char **str, const char **va
>   error("unterminated string constant");
>   }
>   p++;
> - size = p - *str;
> - if (size != 3) {
> + size = p - *str + 1;
> + if (size != 4) {
>   error("empty char string");
>   }
> - tmp = xmalloc(size + 1);
> - (void) strncpy(tmp, *str, size);
> - tmp[size] = 0;
> + tmp = xmalloc(size);
> + (void) strlcpy(tmp, *str, size);
>   *val = tmp;
>   *str = p;
>  }
> @@ -381,10 +379,9 @@ findconst(char **str, const char **val)
>   p++;
>   } while (isdigit(*p));
>   }
> - size = p - *str;
> - tmp = xmalloc(size + 1);
> - (void) strncpy(tmp, *str, size);
> - tmp[size] = 0;
> + size = p - *str + 1;
> + tmp = xmalloc(size);
> + (void) strlcpy(tmp, *str, size);
>   *val = tmp;
>   *str = p;
>  }
> @@ -438,8 +435,7 @@ findkind(char **mark, token *tokp)
>   tokp->kind = TOK_IDENT;
>   for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
>   tmp = xmalloc(len + 1);
> - (void) strncpy(tmp, str, len);
> - tmp[len] = 0;
> + (void) strlcpy(tmp, str, len + 1);
>   tokp->str = tmp;
>   *mark = str + len;
>  }

-- 
Jilles Tjoelker
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r224069 - in head/sys: dev/acpica dev/pci sys x86/include x86/x86

2011-07-15 Thread John Baldwin
Author: jhb
Date: Fri Jul 15 21:08:58 2011
New Revision: 224069
URL: http://svn.freebsd.org/changeset/base/224069

Log:
  Respect the BIOS/firmware's notion of acceptable address ranges for PCI
  resource allocation on x86 platforms:
  - Add a new helper API that Host-PCI bridge drivers can use to restrict
resource allocation requests to a set of address ranges for different
resource types.
  - For the ACPI Host-PCI bridge driver, use Producer address range resources
in _CRS to enumerate valid address ranges for a given Host-PCI bridge.
This can be disabled by including "hostres" in the debug.acpi.disabled
tunable.
  - For the MPTable Host-PCI bridge driver, use entries in the extended
MPTable to determine the valid address ranges for a given Host-PCI
bridge.  This required adding code to parse extended table entries.
  
  Similar to the new PCI-PCI bridge driver, these changes are only enabled
  if the NEW_PCIB kernel option is enabled (which is enabled by default on
  amd64 and i386).
  
  Approved by:  re (kib)

Modified:
  head/sys/dev/acpica/acpi_pcib_acpi.c
  head/sys/dev/pci/pci_pci.c
  head/sys/dev/pci/pci_subr.c
  head/sys/dev/pci/pcib_private.h
  head/sys/sys/bus.h
  head/sys/x86/include/mptable.h
  head/sys/x86/x86/mptable.c
  head/sys/x86/x86/mptable_pci.c

Modified: head/sys/dev/acpica/acpi_pcib_acpi.c
==
--- head/sys/dev/acpica/acpi_pcib_acpi.cFri Jul 15 19:02:44 2011
(r224068)
+++ head/sys/dev/acpica/acpi_pcib_acpi.cFri Jul 15 21:08:58 2011
(r224069)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -62,6 +63,9 @@ struct acpi_hpcib_softc {
 intap_bus; /* bios-assigned bus number */
 
 ACPI_BUFFERap_prt; /* interrupt routing table */
+#ifdef NEW_PCIB
+struct pcib_host_resources ap_host_res;
+#endif
 };
 
 static int acpi_pcib_acpi_probe(device_t bus);
@@ -87,6 +91,11 @@ static struct resource *acpi_pcib_acpi_a
device_t child, int type, int *rid,
u_long start, u_long end, u_long count,
u_int flags);
+#ifdef NEW_PCIB
+static int acpi_pcib_acpi_adjust_resource(device_t dev,
+   device_t child, int type, struct resource *r,
+   u_long start, u_long end);
+#endif
 
 static device_method_t acpi_pcib_acpi_methods[] = {
 /* Device interface */
@@ -101,7 +110,11 @@ static device_method_t acpi_pcib_acpi_me
 DEVMETHOD(bus_read_ivar,   acpi_pcib_read_ivar),
 DEVMETHOD(bus_write_ivar,  acpi_pcib_write_ivar),
 DEVMETHOD(bus_alloc_resource,  acpi_pcib_acpi_alloc_resource),
+#ifdef NEW_PCIB
+DEVMETHOD(bus_adjust_resource, acpi_pcib_acpi_adjust_resource),
+#else
 DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
+#endif
 DEVMETHOD(bus_release_resource,bus_generic_release_resource),
 DEVMETHOD(bus_activate_resource,   bus_generic_activate_resource),
 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
@@ -149,6 +162,120 @@ acpi_pcib_acpi_probe(device_t dev)
 return (0);
 }
 
+#ifdef NEW_PCIB
+static ACPI_STATUS
+acpi_pcib_producer_handler(ACPI_RESOURCE *res, void *context)
+{
+   struct acpi_hpcib_softc *sc;
+   UINT64 length, min, max;
+   u_int flags;
+   int error, type;
+
+   sc = context;
+   switch (res->Type) {
+   case ACPI_RESOURCE_TYPE_START_DEPENDENT:
+   case ACPI_RESOURCE_TYPE_END_DEPENDENT:
+   panic("host bridge has depenedent resources");
+   case ACPI_RESOURCE_TYPE_ADDRESS16:
+   case ACPI_RESOURCE_TYPE_ADDRESS32:
+   case ACPI_RESOURCE_TYPE_ADDRESS64:
+   case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
+   if (res->Data.Address.ProducerConsumer != ACPI_PRODUCER)
+   break;
+   switch (res->Type) {
+   case ACPI_RESOURCE_TYPE_ADDRESS16:
+   min = res->Data.Address16.Minimum;
+   max = res->Data.Address16.Maximum;
+   length = res->Data.Address16.AddressLength;
+   break;
+   case ACPI_RESOURCE_TYPE_ADDRESS32:
+   min = res->Data.Address32.Minimum;
+   max = res->Data.Address32.Maximum;
+   length = res->Data.Address32.AddressLength;
+   break;
+   case ACPI_RESOURCE_TYPE_ADDRESS64:
+   min = res->Data.Address64.Minimum;
+   max = res->Data.Address64.Maximum;
+   length = res->Data.Address64.AddressLength;
+   break;
+   default:
+   KASSERT(res->Type ==
+  

svn commit: r224071 - head/share/misc

2011-07-15 Thread Ryan Steinmetz
Author: zi (ports committer)
Date: Fri Jul 15 21:37:13 2011
New Revision: 224071
URL: http://svn.freebsd.org/changeset/base/224071

Log:
  Add myself to committers-ports.dot
  
  Approved by:  wxs@ (mentor)

Modified:
  head/share/misc/committers-ports.dot

Modified: head/share/misc/committers-ports.dot
==
--- head/share/misc/committers-ports.dotFri Jul 15 21:30:50 2011
(r224070)
+++ head/share/misc/committers-ports.dotFri Jul 15 21:37:13 2011
(r224071)
@@ -183,6 +183,7 @@ wen [label="Wen Heping\n...@freebsd.org\
 wxs [label="Wesley Shields\n...@freebsd.org\n2008/01/03"]
 xride [label="Soeren Straarup\nxr...@freebsd.org\n2006/09/27"]
 yzlin [label="Yi-Jheng Lin\nyz...@freebsd.org\n2009/07/19"]
+zi [label="Ryan Steinmetz\n...@freebsd.org\n2011/07/14"]
 znerd [label="Ernst de Haan\nzn...@freebsd.org\n2001/11/15"]
 
 # Here are the mentor/mentee relationships.
@@ -413,6 +414,7 @@ tabthorpe -> jadawin
 tabthorpe -> jlaffaye
 tabthorpe -> pgj
 tabthorpe -> rene
+tabthorpe -> zi
 
 thierry -> jadawin
 
@@ -428,5 +430,6 @@ wxs -> jsa
 wxs -> sahil
 wxs -> skreuzer
 wxs -> swills
+wxs -> zi
 
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r224072 - head/sys/mips/malta

2011-07-15 Thread Adrian Chadd
Author: adrian
Date: Sat Jul 16 00:30:23 2011
New Revision: 224072
URL: http://svn.freebsd.org/changeset/base/224072

Log:
  The i8259 controller is initialized incorrectly on MALTA.  It writes
  mask bits to control register and control bits to mask register.
  
  The former causes ICW1_RESET|ICW1_LTIM combination to be written to
  control register, which on QEMU results in "level sensitive irq not
  supported" error.
  
  Submitted by: Robert Millan 

Modified:
  head/sys/mips/malta/gt_pci.c

Modified: head/sys/mips/malta/gt_pci.c
==
--- head/sys/mips/malta/gt_pci.cFri Jul 15 21:37:13 2011
(r224071)
+++ head/sys/mips/malta/gt_pci.cSat Jul 16 00:30:23 2011
(r224072)
@@ -326,15 +326,15 @@ gt_pci_attach(device_t dev)
ICW4_8086);
 
/* mask all interrupts */
-   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu1, 0,
+   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu1, 1,
sc->sc_imask & 0xff);
 
/* enable special mask mode */
-   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu1, 1,
+   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu1, 0,
OCW3_SEL | OCW3_ESMM | OCW3_SMM);
 
/* read IRR by default */
-   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu1, 1,
+   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu1, 0,
OCW3_SEL | OCW3_RR);
 
/* reset, program device, 4 bytes */
@@ -348,15 +348,15 @@ gt_pci_attach(device_t dev)
ICW4_8086);
 
/* mask all interrupts */
-   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu2, 0,
+   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu2, 1,
sc->sc_imask & 0xff);
 
/* enable special mask mode */
-   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu2, 1,
+   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu2, 0,
OCW3_SEL | OCW3_ESMM | OCW3_SMM);
 
/* read IRR by default */
-   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu2, 1,
+   bus_space_write_1(sc->sc_st, sc->sc_ioh_icu2, 0,
OCW3_SEL | OCW3_RR);
 
/*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"