Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Mar 2007 22:49:20 GMT
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 115224 for review
Message-ID:  <200703012249.l21MnKIN016136@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=115224

Change 115224 by jkim@jkim_hammer on 2007/03/01 22:49:17

	IFC

Affected files ...

.. //depot/projects/linuxolator/src/sys/dev/ata/ata-chipset.c#10 integrate
.. //depot/projects/linuxolator/src/sys/gnu/fs/ext2fs/ext2_vnops.c#4 integrate
.. //depot/projects/linuxolator/src/sys/kern/kern_jail.c#7 integrate
.. //depot/projects/linuxolator/src/sys/sys/priv.h#6 integrate
.. //depot/projects/linuxolator/src/sys/ufs/ffs/ffs_vnops.c#7 integrate
.. //depot/projects/linuxolator/src/sys/ufs/ufs/ufs_vnops.c#9 integrate

Differences ...

==== //depot/projects/linuxolator/src/sys/dev/ata/ata-chipset.c#10 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.185 2007/02/23 12:18:33 piso Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.186 2007/03/01 21:18:27 sos Exp $");
 
 #include "opt_ata.h"
 #include <sys/param.h>
@@ -55,7 +55,7 @@
 static int ata_generic_chipinit(device_t dev);
 static void ata_generic_intr(void *data);
 static void ata_generic_setmode(device_t dev, int mode);
-static void ata_sata_phy_enable(struct ata_channel *ch);
+static void ata_sata_phy_reset(device_t dev);
 static void ata_sata_phy_event(void *context, int dummy);
 static int ata_sata_connect(struct ata_channel *ch);
 static void ata_sata_setmode(device_t dev, int mode);
@@ -97,7 +97,6 @@
 static int ata_intel_31244_allocate(device_t dev);
 static int ata_intel_31244_status(device_t dev);
 static int ata_intel_31244_command(struct ata_request *request);
-static void ata_intel_31244_reset(device_t dev);
 static int ata_ite_chipinit(device_t dev);
 static void ata_ite_setmode(device_t dev, int mode);
 static int ata_jmicron_chipinit(device_t dev);
@@ -123,7 +122,6 @@
 static int ata_nvidia_chipinit(device_t dev);
 static int ata_nvidia_allocate(device_t dev);
 static int ata_nvidia_status(device_t dev);
-static void ata_nvidia_reset(device_t dev);
 static int ata_promise_chipinit(device_t dev);
 static int ata_promise_allocate(device_t dev);
 static int ata_promise_status(device_t dev);
@@ -159,11 +157,11 @@
 static void ata_sii_setmode(device_t dev, int mode);
 static int ata_sis_chipinit(device_t dev);
 static int ata_sis_allocate(device_t dev);
-static void ata_sis_reset(device_t dev);
 static void ata_sis_setmode(device_t dev, int mode);
 static int ata_via_chipinit(device_t dev);
 static int ata_via_allocate(device_t dev);
 static void ata_via_reset(device_t dev);
+static void ata_via_setmode(device_t dev, int mode);
 static void ata_via_southbridge_fixup(device_t dev);
 static void ata_via_family_setmode(device_t dev, int mode);
 static struct ata_chip_id *ata_match_chip(device_t dev, struct ata_chip_id *index);
@@ -229,8 +227,9 @@
  * SATA support functions
  */
 static void
-ata_sata_phy_enable(struct ata_channel *ch)
+ata_sata_phy_reset(device_t dev)
 {
+    struct ata_channel *ch = device_get_softc(dev);
     int loop, retry;
 
     if ((ATA_IDX_INL(ch, ATA_SCONTROL) & ATA_SC_DET_MASK) == ATA_SC_DET_IDLE) {
@@ -705,7 +704,7 @@
     ATA_OUTL(ctlr->r_res2, ATA_AHCI_P_CMD + offset, ATA_AHCI_P_CMD_SUD);
 
     /* enable interface */
-    ata_sata_phy_enable(ch);
+    ata_sata_phy_reset(dev);
 
     /* no ATAPI yet */
     if (ch->devices & ATA_ATAPI_MASTER) {
@@ -1752,7 +1751,7 @@
 		return ENXIO;
 	    ctlr->channels = 4;
 	    ctlr->allocate = ata_intel_31244_allocate;
-	    ctlr->reset = ata_intel_31244_reset;
+	    ctlr->reset = ata_sata_phy_reset;
 	}
 	ctlr->setmode = ata_sata_setmode;
     }
@@ -2043,15 +2042,7 @@
     return 0;
 }
 
-static void
-ata_intel_31244_reset(device_t dev)
-{
-    struct ata_channel *ch = device_get_softc(dev);
 
-    ata_sata_phy_enable(ch);
-}
-
-
 /*
  * Integrated Technology Express Inc. (ITE) chipset support functions
  */
@@ -2763,7 +2754,7 @@
     ATA_OUTL(ctlr->r_res1, 0x0200c + ATA_MV_EDMA_BASE(ch), ~0x0);
 
     /* enable channel and test for devices */
-    ata_sata_phy_enable(ch);
+    ata_sata_phy_reset(dev);
 
     /* enable EDMA machinery */
     ATA_OUTL(ctlr->r_res1, 0x02028 + ATA_MV_EDMA_BASE(ch), 0x00000001);
@@ -2980,7 +2971,7 @@
 	    int offset = ctlr->chip->cfg2 & NV4 ? 0x0440 : 0x0010;
 
 	    ctlr->allocate = ata_nvidia_allocate;
-	    ctlr->reset = ata_nvidia_reset;
+	    ctlr->reset = ata_sata_phy_reset;
 
 	    /* enable control access */
 	    pci_write_config(dev, 0x50, pci_read_config(dev, 0x50, 1) | 0x04,1);
@@ -3095,15 +3086,7 @@
     return (status & (0x01 << shift));
 }
 
-static void
-ata_nvidia_reset(device_t dev)
-{
-    struct ata_channel *ch = device_get_softc(dev);
 
-    ata_sata_phy_enable(ch);
-}
-
-
 /*
  * Promise chipset support functions
  */
@@ -3772,7 +3755,7 @@
 	if ((ctlr->chip->cfg2 == PRSATA) ||
 	    ((ctlr->chip->cfg2 == PRCMBO) && (ch->unit < 2))) {
 
-	    ata_sata_phy_enable(ch);
+	    ata_sata_phy_reset(dev);
 
 	    /* reset and enable plug/unplug intr */
 	    ATA_OUTL(ctlr->r_res2, 0x06c, (0x00000011 << ch->unit));
@@ -3807,7 +3790,7 @@
 		     (ATA_INL(ctlr->r_res2, 0x414 + (ch->unit << 8)) &
 		     ~0x00000003) | 0x00000001);
 
-	    ata_sata_phy_enable(ch);
+	    ata_sata_phy_reset(dev);
 
 	    /* reset and enable plug/unplug intr */
 	    ATA_OUTL(ctlr->r_res2, 0x060, (0x00000011 << ch->unit));
@@ -4544,7 +4527,7 @@
     ATA_OUTL(ctlr->r_res2, 0x48,
 	     ATA_INL(ctlr->r_res2, 0x48) & ~(0xc0 >> ch->unit));
 
-    ata_sata_phy_enable(ch);
+    ata_sata_phy_reset(dev);
 
     /* enable PHY state change interrupt */
     ATA_OUTL(ctlr->r_res2, 0x148 + offset, (1 << 16));
@@ -4730,7 +4713,7 @@
 	if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
 						   &ctlr->r_rid2, RF_ACTIVE))) {
 	    ctlr->allocate = ata_sis_allocate;
-	    ctlr->reset = ata_sis_reset;
+	    ctlr->reset = ata_sata_phy_reset;
 
 	    /* enable PCI interrupt */
 	    pci_write_config(dev, PCIR_COMMAND,
@@ -4770,15 +4753,6 @@
 }
 
 static void
-ata_sis_reset(device_t dev)
-{
-    struct ata_channel *ch = device_get_softc(dev);
-
-    ata_sata_phy_enable(ch);
-}
-
-
-static void
 ata_sis_setmode(device_t dev, int mode)
 {
     device_t gparent = GRANDPARENT(dev);
@@ -4938,7 +4912,13 @@
 	    pci_write_config(dev, PCIR_COMMAND,
 			     pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2);
 	}
-	ctlr->setmode = ata_sata_setmode;
+
+	if (ctlr->chip->cfg2 & VIABAR) {
+	    ctlr->channels = 3;
+	    ctlr->setmode = ata_via_setmode;
+	}
+	else
+	    ctlr->setmode = ata_sata_setmode;
 	return 0;
     }
 
@@ -4999,6 +4979,8 @@
 	    ch->r_io[i].offset = (i - ATA_BMCMD_PORT)+(ch->unit * ATA_BMIOSIZE);
 	}
 	ata_pci_hw(dev);
+	if (ch->unit > 1)
+	    return 0;
     }
     else {
 	/* setup the usual register normal pci style */
@@ -5022,9 +5004,46 @@
 static void
 ata_via_reset(device_t dev)
 {
+    struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
 
-    ata_sata_phy_enable(ch);
+    if ((ctlr->chip->cfg2 & VIABAR) && (ch->unit > 1))
+	ata_generic_reset(dev);
+    else
+	ata_sata_phy_reset(dev);
+}
+
+static void
+ata_via_setmode(device_t dev, int mode)
+{
+    device_t gparent = GRANDPARENT(dev);
+    struct ata_pci_controller *ctlr = device_get_softc(gparent);
+    struct ata_channel *ch = device_get_softc(device_get_parent(dev));
+    struct ata_device *atadev = device_get_softc(dev);
+    int error;
+
+    if ((ctlr->chip->cfg2 & VIABAR) && (ch->unit > 1)) {
+        u_int8_t pio_timings[] = { 0xa8, 0x65, 0x65, 0x32, 0x20,
+				   0x65, 0x32, 0x20,
+				   0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
+        u_int8_t dma_timings[] = { 0xee, 0xe8, 0xe6, 0xe4, 0xe2, 0xe1, 0xe0 };
+
+	mode = ata_check_80pin(dev, ata_limit_mode(dev, mode, ATA_UDMA6));
+	error = ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode);
+	if (bootverbose)
+	    device_printf(dev, "%ssetting %s on %s chip\n",
+			  (error) ? "FAILURE " : "", ata_mode2str(mode),
+			  ctlr->chip->text);
+	if (!error) {
+	    pci_write_config(gparent, 0xab, pio_timings[ata_mode2idx(mode)], 1);
+	    if (mode >= ATA_UDMA0)
+		pci_write_config(gparent, 0xb3,
+				 dma_timings[mode & ATA_MODE_MASK], 1);
+	    atadev->mode = mode;
+	}
+    }
+    else
+	ata_sata_setmode(dev, mode);
 }
 
 static void
@@ -5065,7 +5084,7 @@
     struct ata_channel *ch = device_get_softc(device_get_parent(dev));
     struct ata_device *atadev = device_get_softc(dev);
     u_int8_t timings[] = { 0xa8, 0x65, 0x42, 0x22, 0x20, 0x42, 0x22, 0x20,
-			   0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
+			   0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
     int modes[][7] = {
 	{ 0xc2, 0xc1, 0xc0, 0x00, 0x00, 0x00, 0x00 },   /* VIA ATA33 */
 	{ 0xee, 0xec, 0xea, 0xe9, 0xe8, 0x00, 0x00 },   /* VIA ATA66 */

==== //depot/projects/linuxolator/src/sys/gnu/fs/ext2fs/ext2_vnops.c#4 (text+ko) ====

@@ -39,7 +39,7 @@
  *
  *	@(#)ufs_vnops.c	8.7 (Berkeley) 2/3/94
  *	@(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95
- * $FreeBSD: src/sys/gnu/fs/ext2fs/ext2_vnops.c,v 1.107 2007/02/15 22:08:34 pjd Exp $
+ * $FreeBSD: src/sys/gnu/fs/ext2fs/ext2_vnops.c,v 1.109 2007/03/01 20:47:41 pjd Exp $
  */
 
 #include "opt_suiddir.h"
@@ -596,8 +596,8 @@
 	ip->i_gid = gid;
 	ip->i_uid = uid;
 	ip->i_flag |= IN_CHANGE;
-	if (ouid != uid || ogid != gid) {
-		if (priv_check_cred(cred, PRIV_VFS_CLEARSUGID,
+	if ((ip->i_mode & (ISUID | ISGID)) && (ouid != uid || ogid != gid)) {
+		if (priv_check_cred(cred, PRIV_VFS_RETAINSUGID,
 		    SUSER_ALLOWJAIL) != 0)
 			ip->i_mode &= ~(ISUID | ISGID);
 	}
@@ -1648,7 +1648,7 @@
 	tvp->v_type = IFTOVT(mode);	/* Rest init'd in getnewvnode(). */
 	ip->i_nlink = 1;
 	if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred)) {
-		if (priv_check_cred(cnp->cn_cred, PRIV_VFS_CLEARSUGID,
+		if (priv_check_cred(cnp->cn_cred, PRIV_VFS_RETAINSUGID,
 		    SUSER_ALLOWJAIL))
 			ip->i_mode &= ~ISGID;
 	}

==== //depot/projects/linuxolator/src/sys/kern/kern_jail.c#7 (text+ko) ====

@@ -8,7 +8,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_jail.c,v 1.58 2007/02/20 00:12:52 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_jail.c,v 1.59 2007/03/01 20:47:41 pjd Exp $");
 
 #include "opt_mac.h"
 
@@ -638,7 +638,7 @@
 	case PRIV_VFS_CHFLAGS_DEV:
 	case PRIV_VFS_CHOWN:
 	case PRIV_VFS_CHROOT:
-	case PRIV_VFS_CLEARSUGID:
+	case PRIV_VFS_RETAINSUGID:
 	case PRIV_VFS_FCHROOT:
 	case PRIV_VFS_LINK:
 	case PRIV_VFS_SETGID:

==== //depot/projects/linuxolator/src/sys/sys/priv.h#6 (text+ko) ====

@@ -26,7 +26,7 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/sys/priv.h,v 1.6 2007/02/27 23:38:58 pjd Exp $
+ * $FreeBSD: src/sys/sys/priv.h,v 1.7 2007/03/01 20:47:42 pjd Exp $
  */
 
 /*
@@ -238,7 +238,7 @@
 #define	PRIV_VFS_CHFLAGS_DEV	316	/* Can chflags() a device node. */
 #define	PRIV_VFS_CHOWN		317	/* Can set user; group to non-member. */
 #define	PRIV_VFS_CHROOT		318	/* chroot(). */
-#define	PRIV_VFS_CLEARSUGID	319	/* Don't clear sugid on change. */
+#define	PRIV_VFS_RETAINSUGID	319	/* Can retain sugid bits on change. */
 #define	PRIV_VFS_EXCEEDQUOTA	320	/* Exempt from quota restrictions. */
 #define	PRIV_VFS_EXTATTR_SYSTEM	321	/* Operate on system EA namespace. */
 #define	PRIV_VFS_FCHROOT	322	/* fchroot(). */

==== //depot/projects/linuxolator/src/sys/ufs/ffs/ffs_vnops.c#7 (text+ko) ====

@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/ufs/ffs/ffs_vnops.c,v 1.165 2007/02/21 08:50:06 mckusick Exp $");
+__FBSDID("$FreeBSD: src/sys/ufs/ffs/ffs_vnops.c,v 1.167 2007/03/01 20:47:41 pjd Exp $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -788,11 +788,13 @@
 	 * we clear the setuid and setgid bits as a precaution against
 	 * tampering.
 	 */
-	if (resid > uio->uio_resid && ap->a_cred && 
-	    priv_check_cred(ap->a_cred, PRIV_VFS_CLEARSUGID,
-	    SUSER_ALLOWJAIL)) {
-		ip->i_mode &= ~(ISUID | ISGID);
-		DIP_SET(ip, i_mode, ip->i_mode);
+	if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid &&
+	    ap->a_cred) {
+		if (priv_check_cred(ap->a_cred, PRIV_VFS_RETAINSUGID,
+		    SUSER_ALLOWJAIL)) {
+			ip->i_mode &= ~(ISUID | ISGID);
+			DIP_SET(ip, i_mode, ip->i_mode);
+		}
 	}
 	if (error) {
 		if (ioflag & IO_UNIT) {
@@ -1115,10 +1117,12 @@
 	 * we clear the setuid and setgid bits as a precaution against
 	 * tampering.
 	 */
-	if (resid > uio->uio_resid && ucred && 
-	    priv_check_cred(ucred, PRIV_VFS_CLEARSUGID, SUSER_ALLOWJAIL)) {
-		ip->i_mode &= ~(ISUID | ISGID);
-		dp->di_mode = ip->i_mode;
+	if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid && ucred) {
+		if (priv_check_cred(ap->a_cred, PRIV_VFS_RETAINSUGID,
+		    SUSER_ALLOWJAIL)) {
+			ip->i_mode &= ~(ISUID | ISGID);
+			dp->di_mode = ip->i_mode;
+		}
 	}
 	if (error) {
 		if (ioflag & IO_UNIT) {

==== //depot/projects/linuxolator/src/sys/ufs/ufs/ufs_vnops.c#9 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/ufs/ufs/ufs_vnops.c,v 1.285 2007/02/08 09:47:19 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/ufs/ufs/ufs_vnops.c,v 1.288 2007/03/01 21:44:08 pjd Exp $");
 
 #include "opt_mac.h"
 #include "opt_quota.h"
@@ -584,7 +584,7 @@
 		 * the file or be the super-user.
 		 *
 		 * Possibly for historical reasons, try to use VADMIN in
-		 * preference to VADMIN for a NULL timestamp.  This means we
+		 * preference to VWRITE for a NULL timestamp.  This means we
 		 * will return EACCES in preference to EPERM if neither
 		 * check succeeds.
 		 */
@@ -786,10 +786,12 @@
 		panic("ufs_chown: lost quota");
 #endif /* QUOTA */
 	ip->i_flag |= IN_CHANGE;
-	if (priv_check_cred(cred, PRIV_VFS_CLEARSUGID, SUSER_ALLOWJAIL) &&
-	    (ouid != uid || ogid != gid)) {
-		ip->i_mode &= ~(ISUID | ISGID);
-		DIP_SET(ip, i_mode, ip->i_mode);
+	if ((ip->i_mode & (ISUID | ISGID)) && (ouid != uid || ogid != gid)) {
+		if (priv_check_cred(cred, PRIV_VFS_RETAINSUGID,
+		    SUSER_ALLOWJAIL)) {
+			ip->i_mode &= ~(ISUID | ISGID);
+			DIP_SET(ip, i_mode, ip->i_mode);
+		}
 	}
 	return (0);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703012249.l21MnKIN016136>