svn commit: r198381 - head/sys/cam/scsi

2009-10-23 Thread Alexander Motin
Author: mav
Date: Fri Oct 23 07:54:15 2009
New Revision: 198381
URL: http://svn.freebsd.org/changeset/base/198381

Log:
  Remove some obsoleted comments.

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Fri Oct 23 07:36:12 2009(r198380)
+++ head/sys/cam/scsi/scsi_da.c Fri Oct 23 07:54:15 2009(r198381)
@@ -813,19 +813,6 @@ dastrategy(struct bio *bp)
 
cam_periph_lock(periph);
 
-#if 0
-   /*
-* check it's not too big a transfer for our adapter
-*/
-   scsi_minphys(bp,sd_switch);
-#endif
-
-   /*
-* Mask interrupts so that the pack cannot be invalidated until
-* after we are in the queue.  Otherwise, we might not properly
-* clean up one of the buffers.
-*/
-   
/*
 * If the device has been made invalid, error out
 */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198382 - in head/sys/cam: . ata scsi

2009-10-23 Thread Alexander Motin
Author: mav
Date: Fri Oct 23 08:27:55 2009
New Revision: 198382
URL: http://svn.freebsd.org/changeset/base/198382

Log:
  Replace most of priority numbers with defines. No logical changes.

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/ata/ata_xpt.c
  head/sys/cam/cam.h
  head/sys/cam/cam_periph.c
  head/sys/cam/cam_xpt.c
  head/sys/cam/scsi/scsi_all.c
  head/sys/cam/scsi/scsi_cd.c
  head/sys/cam/scsi/scsi_ch.c
  head/sys/cam/scsi/scsi_da.c
  head/sys/cam/scsi/scsi_pt.c
  head/sys/cam/scsi/scsi_sa.c
  head/sys/cam/scsi/scsi_targ_bh.c
  head/sys/cam/scsi/scsi_target.c
  head/sys/cam/scsi/scsi_xpt.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Fri Oct 23 07:54:15 2009(r198381)
+++ head/sys/cam/ata/ata_da.c   Fri Oct 23 08:27:55 2009(r198382)
@@ -270,7 +270,7 @@ adaclose(struct disk *dp)
/* We only sync the cache if the drive is capable of it. */
if (softc-flags  ADA_FLAG_CAN_FLUSHCACHE) {
 
-   ccb = cam_periph_getccb(periph, /*priority*/1);
+   ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
cam_fill_ataio(ccb-ataio,
1,
adadone,
@@ -343,7 +343,7 @@ adastrategy(struct bio *bp)
/*
 * Schedule ourselves for performing the work.
 */
-   xpt_schedule(periph, /* XXX priority */1);
+   xpt_schedule(periph, CAM_PRIORITY_NORMAL);
cam_periph_unlock(periph);
 
return;
@@ -377,7 +377,7 @@ adadump(void *arg, void *virtual, vm_off
 
if (length  0) {
periph-flags |= CAM_PERIPH_POLLED;
-   xpt_setup_ccb(ccb.ccb_h, periph-path, /*priority*/1);
+   xpt_setup_ccb(ccb.ccb_h, periph-path, CAM_PRIORITY_NORMAL);
ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
cam_fill_ataio(ccb.ataio,
0,
@@ -408,7 +408,7 @@ adadump(void *arg, void *virtual, vm_off
}
 
if (softc-flags  ADA_FLAG_CAN_FLUSHCACHE) {
-   xpt_setup_ccb(ccb.ccb_h, periph-path, /*priority*/1);
+   xpt_setup_ccb(ccb.ccb_h, periph-path, CAM_PRIORITY_NORMAL);
 
ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
cam_fill_ataio(ccb.ataio,
@@ -563,7 +563,7 @@ adaasync(void *callback_arg, u_int32_t c
 */
softc-state = ADA_STATE_SET_MULTI;
cam_periph_acquire(periph);
-   xpt_schedule(periph, 0);
+   xpt_schedule(periph, CAM_PRIORITY_DEV);
break;
}
default:
@@ -665,7 +665,7 @@ adaregister(struct cam_periph *periph, v
 
/* Check if the SIM does not want queued commands */
bzero(cpi, sizeof(cpi));
-   xpt_setup_ccb(cpi.ccb_h, periph-path, /*priority*/1);
+   xpt_setup_ccb(cpi.ccb_h, periph-path, CAM_PRIORITY_NORMAL);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *)cpi);
if (cpi.ccb_h.status != CAM_REQ_CMP ||
@@ -897,7 +897,7 @@ adastart(struct cam_periph *periph, unio

if (bp != NULL) {
/* Have more work to do, so ensure we stay scheduled */
-   xpt_schedule(periph, /* XXX priority */1);
+   xpt_schedule(periph, CAM_PRIORITY_NORMAL);
}
break;
}
@@ -1027,7 +1027,7 @@ adadone(struct cam_periph *periph, union
xpt_release_ccb(done_ccb);
if (bioq_first(softc-bio_queue) != NULL) {
/* Have more work to do, so ensure we stay scheduled */
-   xpt_schedule(periph, 1);
+   xpt_schedule(periph, CAM_PRIORITY_NORMAL);
}
cam_periph_release_locked(periph);
return;
@@ -1139,7 +1139,7 @@ adashutdown(void * arg, int howto)
continue;
}
 
-   xpt_setup_ccb(ccb.ccb_h, periph-path, /*priority*/1);
+   xpt_setup_ccb(ccb.ccb_h, periph-path, CAM_PRIORITY_NORMAL);
 
ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
cam_fill_ataio(ccb.ataio,

Modified: head/sys/cam/ata/ata_xpt.c
==
--- head/sys/cam/ata/ata_xpt.c  Fri Oct 23 07:54:15 2009(r198381)
+++ head/sys/cam/ata/ata_xpt.c  Fri Oct 23 08:27:55 2009(r198382)
@@ -270,7 +270,7 @@ probeschedule(struct cam_periph *periph)
softc = (probe_softc *)periph-softc;
ccb = (union ccb *)TAILQ_FIRST(softc-request_ccbs);
 
-   xpt_setup_ccb(cpi.ccb_h, periph-path, /*priority*/1);
+   xpt_setup_ccb(cpi.ccb_h, periph-path, CAM_PRIORITY_NORMAL);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *)cpi);
 
@@ -506,7 +506,7 @@ proberequestdefaultnegotiation(struct ca
 {

svn commit: r198383 - head/etc/rc.d

2009-10-23 Thread Hiroki Sato
Author: hrs
Date: Fri Oct 23 09:30:19 2009
New Revision: 198383
URL: http://svn.freebsd.org/changeset/base/198383

Log:
  Use double-quotation marks to fix the unexpanded variable issue.
  
  Spotted by:   swell.k

Modified:
  head/etc/rc.d/netoptions

Modified: head/etc/rc.d/netoptions
==
--- head/etc/rc.d/netoptionsFri Oct 23 08:27:55 2009(r198382)
+++ head/etc/rc.d/netoptionsFri Oct 23 09:30:19 2009(r198383)
@@ -53,7 +53,7 @@ netoptions_inet()
${SYSCTL_W} net.inet.tcp.rfc1323=1 /dev/null
else
netoptions_init
-   echo -n ' rfc1323 extensions=${tcp_extensions}'
+   echo -n  rfc1323 extensions=${tcp_extensions}
${SYSCTL_W} net.inet.tcp.rfc1323=0 /dev/null
fi
 
@@ -61,13 +61,13 @@ netoptions_inet()
${SYSCTL_W} net.inet.tcp.always_keepalive=1 /dev/null
else
netoptions_init
-   echo -n ' TCP keepalive=${tcp_keepalive}'
+   echo -n  TCP keepalive=${tcp_keepalive}
${SYSCTL_W} net.inet.tcp.always_keepalive=0 /dev/null
fi
 
if checkyesno tcp_drop_synfin; then
netoptions_init
-   echo -n ' drop SYN+FIN packets=${tcp_drop_synfin}'
+   echo -n  drop SYN+FIN packets=${tcp_drop_synfin}
${SYSCTL_W} net.inet.tcp.drop_synfin=1 /dev/null
else
${SYSCTL_W} net.inet.tcp.drop_synfin=0 /dev/null
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198384 - head/sys/net80211

2009-10-23 Thread Rui Paulo
Author: rpaulo
Date: Fri Oct 23 11:13:08 2009
New Revision: 198384
URL: http://svn.freebsd.org/changeset/base/198384

Log:
  The draft spec doesn't say beacon frames need to have a wildcard BSSID,
  so remove the mesh code necessary for that.
  
  MFC after:2 days

Modified:
  head/sys/net80211/ieee80211_output.c

Modified: head/sys/net80211/ieee80211_output.c
==
--- head/sys/net80211/ieee80211_output.cFri Oct 23 09:30:19 2009
(r198383)
+++ head/sys/net80211/ieee80211_output.cFri Oct 23 11:13:08 2009
(r198384)
@@ -2764,13 +2764,7 @@ ieee80211_beacon_alloc(struct ieee80211_
*(uint16_t *)wh-i_dur = 0;
IEEE80211_ADDR_COPY(wh-i_addr1, ifp-if_broadcastaddr);
IEEE80211_ADDR_COPY(wh-i_addr2, vap-iv_myaddr);
-#ifdef IEEE80211_SUPPORT_MESH
-   if (vap-iv_opmode == IEEE80211_M_MBSS) {
-   static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
-   IEEE80211_ADDR_COPY(wh-i_addr3, zerobssid);
-   } else
-#endif
-   IEEE80211_ADDR_COPY(wh-i_addr3, ni-ni_bssid);
+   IEEE80211_ADDR_COPY(wh-i_addr3, ni-ni_bssid);
*(uint16_t *)wh-i_seq = 0;
 
return m;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198385 - head/sys/cam

2009-10-23 Thread Alexander Motin
Author: mav
Date: Fri Oct 23 11:26:58 2009
New Revision: 198385
URL: http://svn.freebsd.org/changeset/base/198385

Log:
  Fix the build.

Modified:
  head/sys/cam/cam_xpt.c

Modified: head/sys/cam/cam_xpt.c
==
--- head/sys/cam/cam_xpt.c  Fri Oct 23 11:13:08 2009(r198384)
+++ head/sys/cam/cam_xpt.c  Fri Oct 23 11:26:58 2009(r198385)
@@ -812,7 +812,7 @@ xpt_scanner_thread(void *dummy)
else
ccb-ccb_h.func_code = XPT_SCAN_LUN;
ccb-ccb_h.cbfcnp = xptdone;
-   xpt_setup_ccb(ccb-ccb_h, ccb-ccb_h.path, 
CAM_PRIORITY_BUS);
+   xpt_setup_ccb(ccb-ccb_h, ccb-ccb_h.path, 
CAM_PRIORITY_NORMAL);
cam_periph_runccb(ccb, NULL, 0, 0, NULL);
xpt_free_path(ccb-ccb_h.path);
xpt_free_ccb(ccb);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198386 - stable/8/lib/libusb

2009-10-23 Thread Andrew Thompson
Author: thompsa
Date: Fri Oct 23 12:02:01 2009
New Revision: 198386
URL: http://svn.freebsd.org/changeset/base/198386

Log:
  MFC r198376
  
   Prevent wraparound of the timeout variable.
  
  Submitted by: HPS
  Approved by:  re (kib)

Modified:
  stable/8/lib/libusb/   (props changed)
  stable/8/lib/libusb/libusb20_ugen20.c
  stable/8/lib/libusb/usb.h   (props changed)

Modified: stable/8/lib/libusb/libusb20_ugen20.c
==
--- stable/8/lib/libusb/libusb20_ugen20.c   Fri Oct 23 11:26:58 2009
(r198385)
+++ stable/8/lib/libusb/libusb20_ugen20.c   Fri Oct 23 12:02:01 2009
(r198386)
@@ -800,7 +800,11 @@ ugen20_tr_submit(struct libusb20_transfe
if (xfer-flags  LIBUSB20_TRANSFER_DO_CLEAR_STALL) {
fsep-flags |= USB_FS_FLAG_CLEAR_STALL;
}
-   fsep-timeout = xfer-timeout;
+   /* NOTE: The fsep-timeout variable is 16-bit. */
+   if (xfer-timeout  65535)
+   fsep-timeout = 65535;
+   else
+   fsep-timeout = xfer-timeout;
 
temp.ep_index = xfer-trIndex;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198389 - in head/sys: cam/ata conf modules/cam

2009-10-23 Thread Alexander Motin
Author: mav
Date: Fri Oct 23 12:36:42 2009
New Revision: 198389
URL: http://svn.freebsd.org/changeset/base/198389

Log:
  MFp4:
  Move Port Multiplier support code out of ATA XPT into pmp periph driver.
  This is convinient, as PMP itself is a bus target and has own state.

Added:
  head/sys/cam/ata/ata_pmp.c   (contents, props changed)
Modified:
  head/sys/cam/ata/ata_xpt.c
  head/sys/conf/files
  head/sys/modules/cam/Makefile

Added: head/sys/cam/ata/ata_pmp.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/cam/ata/ata_pmp.c  Fri Oct 23 12:36:42 2009(r198389)
@@ -0,0 +1,735 @@
+/*-
+ * Copyright (c) 2009 Alexander Motin m...@freebsd.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer,
+ *without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include sys/cdefs.h
+__FBSDID($FreeBSD$);
+
+#include sys/param.h
+
+#ifdef _KERNEL
+#include sys/systm.h
+#include sys/kernel.h
+#include sys/bio.h
+#include sys/sysctl.h
+#include sys/taskqueue.h
+#include sys/lock.h
+#include sys/mutex.h
+#include sys/conf.h
+#include sys/devicestat.h
+#include sys/eventhandler.h
+#include sys/malloc.h
+#include sys/cons.h
+#include geom/geom_disk.h
+#endif /* _KERNEL */
+
+#ifndef _KERNEL
+#include stdio.h
+#include string.h
+#endif /* _KERNEL */
+
+#include cam/cam.h
+#include cam/cam_ccb.h
+#include cam/cam_periph.h
+#include cam/cam_xpt_periph.h
+#include cam/cam_sim.h
+
+#include cam/ata/ata_all.h
+
+#ifdef _KERNEL
+
+typedef enum {
+   PMP_STATE_NORMAL,
+   PMP_STATE_PORTS,
+   PMP_STATE_CONFIG,
+   PMP_STATE_RESET,
+   PMP_STATE_CONNECT,
+   PMP_STATE_CHECK,
+   PMP_STATE_CLEAR,
+   PMP_STATE_SCAN
+} pmp_state;
+
+typedef enum {
+   PMP_FLAG_SCTX_INIT  = 0x200
+} pmp_flags;
+
+typedef enum {
+   PMP_CCB_PROBE   = 0x01,
+} pmp_ccb_state;
+
+/* Offsets into our private area for storing information */
+#define ccb_state  ppriv_field0
+#define ccb_bp ppriv_ptr1
+
+struct pmp_softc {
+   SLIST_ENTRY(pmp_softc)  links;
+   pmp_state   state;
+   pmp_flags   flags;
+   uint32_tpm_pid;
+   uint32_tpm_prv;
+   int pm_ports;
+   int pm_step;
+   int pm_try;
+   int found;
+   int frozen;
+   union   ccb saved_ccb;
+   struct task sysctl_task;
+   struct sysctl_ctx_list  sysctl_ctx;
+   struct sysctl_oid   *sysctl_tree;
+};
+
+static periph_init_t   pmpinit;
+static voidpmpasync(void *callback_arg, u_int32_t code,
+   struct cam_path *path, void *arg);
+static voidpmpsysctlinit(void *context, int pending);
+static periph_ctor_t   pmpregister;
+static periph_dtor_t   pmpcleanup;
+static periph_start_t  pmpstart;
+static periph_oninv_t  pmponinvalidate;
+static voidpmpdone(struct cam_periph *periph,
+  union ccb *done_ccb);
+
+#ifndef PMP_DEFAULT_TIMEOUT
+#define PMP_DEFAULT_TIMEOUT 30 /* Timeout in seconds */
+#endif
+
+#ifndefPMP_DEFAULT_RETRY
+#definePMP_DEFAULT_RETRY   1
+#endif
+
+static int pmp_retry_count = PMP_DEFAULT_RETRY;
+static int pmp_default_timeout = PMP_DEFAULT_TIMEOUT;
+
+SYSCTL_NODE(_kern_cam, OID_AUTO, pmp, CTLFLAG_RD, 0,
+CAM Direct Access Disk driver);
+SYSCTL_INT(_kern_cam_pmp, OID_AUTO, retry_count, CTLFLAG_RW,
+   pmp_retry_count, 0, Normal I/O retry count);
+TUNABLE_INT(kern.cam.pmp.retry_count, pmp_retry_count);

svn commit: r198390 - head/sys/dev/ahci

2009-10-23 Thread Alexander Motin
Author: mav
Date: Fri Oct 23 13:07:22 2009
New Revision: 198390
URL: http://svn.freebsd.org/changeset/base/198390

Log:
  Revert interrupt reason check order back.
  ATAPI errors may set IF bit together with TFE.

Modified:
  head/sys/dev/ahci/ahci.c

Modified: head/sys/dev/ahci/ahci.c
==
--- head/sys/dev/ahci/ahci.cFri Oct 23 12:36:42 2009(r198389)
+++ head/sys/dev/ahci/ahci.cFri Oct 23 13:07:22 2009(r198390)
@@ -1001,12 +1001,7 @@ ahci_ch_intr(void *data)
/* XXX: reqests in loading state. */
if (((err  i)  1) == 0)
continue;
-   if (istatus  AHCI_P_IX_IF) {
-   if (ch-numtslots == 0  i != ccs)
-   et = AHCI_ERR_INNOCENT;
-   else
-   et = AHCI_ERR_SATA;
-   } else if (istatus  AHCI_P_IX_TFE) {
+   if (istatus  AHCI_P_IX_TFE) {
/* Task File Error */
if (ch-numtslots == 0) {
/* Untagged operation. */
@@ -1019,6 +1014,11 @@ ahci_ch_intr(void *data)
et = AHCI_ERR_NCQ;
ncq_err = 1;
}
+   } else if (istatus  AHCI_P_IX_IF) {
+   if (ch-numtslots == 0  i != ccs)
+   et = AHCI_ERR_INNOCENT;
+   else
+   et = AHCI_ERR_SATA;
} else
et = AHCI_ERR_INVALID;
ahci_end_transaction(ch-slot[i], et);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198391 - head/sys/sys

2009-10-23 Thread John Baldwin
Author: jhb
Date: Fri Oct 23 13:28:33 2009
New Revision: 198391
URL: http://svn.freebsd.org/changeset/base/198391

Log:
  Properly sort the intr_event_describe_handler() prototype.
  
  Submitted by: bde

Modified:
  head/sys/sys/interrupt.h

Modified: head/sys/sys/interrupt.h
==
--- head/sys/sys/interrupt.hFri Oct 23 13:07:22 2009(r198390)
+++ head/sys/sys/interrupt.hFri Oct 23 13:28:33 2009(r198391)
@@ -168,12 +168,12 @@ int   intr_event_create(struct intr_event 
void (*post_ithread)(void *), void (*post_filter)(void *),
int (*assign_cpu)(void *, u_char), const char *fmt, ...)
__printflike(9, 10);
+intintr_event_describe_handler(struct intr_event *ie, void *cookie,
+   const char *descr);
 intintr_event_destroy(struct intr_event *ie);
 void   intr_event_execute_handlers(struct proc *p, struct intr_event *ie);
 intintr_event_handle(struct intr_event *ie, struct trapframe *frame);
 intintr_event_remove_handler(void *cookie);
-intintr_event_describe_handler(struct intr_event *ie, void *cookie,
-   const char *descr);
 intintr_getaffinity(int irq, void *mask);
 void   *intr_handler_source(void *cookie);
 intintr_setaffinity(int irq, void *mask);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198393 - head/sys/netinet

2009-10-23 Thread Robert Watson
Author: rwatson
Date: Fri Oct 23 13:35:00 2009
New Revision: 198393
URL: http://svn.freebsd.org/changeset/base/198393

Log:
  Improve grammar in ip_input comment while attempting to maintain what
  might be its meaning.
  
  MFC after:3 days

Modified:
  head/sys/netinet/ip_input.c

Modified: head/sys/netinet/ip_input.c
==
--- head/sys/netinet/ip_input.c Fri Oct 23 13:32:26 2009(r198392)
+++ head/sys/netinet/ip_input.c Fri Oct 23 13:35:00 2009(r198393)
@@ -530,8 +530,8 @@ tooshort:
}
if ((dchg = (m_tag_find(m, PACKET_TAG_IPFORWARD, NULL) != NULL)) != 0) {
/*
-* Directly ship on the packet.  This allows to forward
-* packets that were destined for us to some other directly
+* Directly ship the packet on.  This allows forwarding
+* packets originally destined to us to ome other directly
 * connected host.
 */
ip_forward(m, dchg);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198394 - head/sys/cam

2009-10-23 Thread Alexander Motin
Author: mav
Date: Fri Oct 23 13:39:30 2009
New Revision: 198394
URL: http://svn.freebsd.org/changeset/base/198394

Log:
  Make Retrying Command to be printed before actual retrying.
  It should make debug/error log a bit more readable.

Modified:
  head/sys/cam/cam_periph.c

Modified: head/sys/cam/cam_periph.c
==
--- head/sys/cam/cam_periph.c   Fri Oct 23 13:35:00 2009(r198393)
+++ head/sys/cam/cam_periph.c   Fri Oct 23 13:39:30 2009(r198394)
@@ -1767,16 +1767,27 @@ cam_periph_error(union ccb *ccb, cam_fla
break;
}
 
+   /*
+* If we have and error and are booting verbosely, whine
+* *unless* this was a non-retryable selection timeout.
+*/
+   if (error != 0  bootverbose 
+   !(status == CAM_SEL_TIMEOUT  (camflags  CAM_RETRY_SELTO) == 0)) {
+   if (error != ERESTART) {
+   if (action_string == NULL)
+   action_string = Unretryable Error;
+   xpt_print(ccb-ccb_h.path, error %d\n, error);
+   xpt_print(ccb-ccb_h.path, %s\n, action_string);
+   } else
+   xpt_print(ccb-ccb_h.path, Retrying Command\n);
+   }
+
/* Attempt a retry */
-   if (error == ERESTART || error == 0) {  
+   if (error == ERESTART || error == 0) {
if (frozen != 0)
ccb-ccb_h.status = ~CAM_DEV_QFRZN;
-
-   if (error == ERESTART) {
-   action_string = Retrying Command;
+   if (error == ERESTART)
xpt_action(ccb);
-   }
-   
if (frozen != 0)
cam_release_devq(ccb-ccb_h.path,
 relsim_flags,
@@ -1785,21 +1796,5 @@ cam_periph_error(union ccb *ccb, cam_fla
 /*getcount_only*/0);
}
 
-   /*
-* If we have and error and are booting verbosely, whine
-* *unless* this was a non-retryable selection timeout.
-*/
-   if (error != 0  bootverbose 
-   !(status == CAM_SEL_TIMEOUT  (camflags  CAM_RETRY_SELTO) == 0)) {
-
-
-   if (action_string == NULL)
-   action_string = Unretryable Error;
-   if (error != ERESTART) {
-   xpt_print(ccb-ccb_h.path, error %d\n, error);
-   }
-   xpt_print(ccb-ccb_h.path, %s\n, action_string);
-   }
-
return (error);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198397 - vendor/llvm/llvm-r84949

2009-10-23 Thread Roman Divacky
Author: rdivacky
Date: Fri Oct 23 14:21:22 2009
New Revision: 198397
URL: http://svn.freebsd.org/changeset/base/198397

Log:
  Tag LLVM r84949.

Added:
  vendor/llvm/llvm-r84949/
 - copied from r198396, vendor/llvm/dist/
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198398 - in vendor/clang/dist: include/clang-c include/clang/AST include/clang/Analysis/PathSensitive include/clang/Analysis/Support include/clang/Basic include/clang/Frontend include/...

2009-10-23 Thread Roman Divacky
Author: rdivacky
Date: Fri Oct 23 14:22:18 2009
New Revision: 198398
URL: http://svn.freebsd.org/changeset/base/198398

Log:
  Update clang to r84949.

Added:
  vendor/clang/dist/include/clang/AST/TypeLocBuilder.h
  vendor/clang/dist/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp
  vendor/clang/dist/test/CXX/temp/temp.spec/p5.cpp
  vendor/clang/dist/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
  vendor/clang/dist/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp
  vendor/clang/dist/test/CXX/temp/temp.spec/temp.explicit/p1.cpp
  vendor/clang/dist/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
  vendor/clang/dist/test/CXX/temp/temp.spec/temp.explicit/p3.cpp
  vendor/clang/dist/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
  vendor/clang/dist/test/CodeGen/2009-10-20-GlobalDebug.c
  vendor/clang/dist/test/CodeGenCXX/address-of-fntemplate.cpp
  vendor/clang/dist/test/CodeGenCXX/call-arg-zero-temp.cpp
  vendor/clang/dist/test/CodeGenCXX/casts.cpp
  vendor/clang/dist/test/CodeGenCXX/derived-to-base-conv.cpp
  vendor/clang/dist/test/CodeGenCXX/ptr-to-datamember.cpp
  vendor/clang/dist/test/CodeGenCXX/temporaries.cpp
  vendor/clang/dist/test/Driver/cxx-pth.cpp
  vendor/clang/dist/test/Index/c-index-pch.c
  vendor/clang/dist/test/Index/c-index-pch.h
  vendor/clang/dist/test/SemaCXX/ptrtomember-overload-resolution.cpp
  vendor/clang/dist/test/SemaCXX/switch.cpp
  vendor/clang/dist/www/UniversalDriver.html
Modified:
  vendor/clang/dist/include/clang-c/Index.h
  vendor/clang/dist/include/clang/AST/ASTContext.h
  vendor/clang/dist/include/clang/AST/Attr.h
  vendor/clang/dist/include/clang/AST/CXXInheritance.h
  vendor/clang/dist/include/clang/AST/CanonicalType.h
  vendor/clang/dist/include/clang/AST/Decl.h
  vendor/clang/dist/include/clang/AST/DeclBase.h
  vendor/clang/dist/include/clang/AST/DeclObjC.h
  vendor/clang/dist/include/clang/AST/Expr.h
  vendor/clang/dist/include/clang/AST/Type.h
  vendor/clang/dist/include/clang/AST/TypeLoc.h
  vendor/clang/dist/include/clang/AST/TypeLocNodes.def
  vendor/clang/dist/include/clang/AST/TypeLocVisitor.h
  vendor/clang/dist/include/clang/AST/TypeNodes.def
  vendor/clang/dist/include/clang/Analysis/PathSensitive/AnalysisContext.h
  vendor/clang/dist/include/clang/Analysis/PathSensitive/AnalysisManager.h
  vendor/clang/dist/include/clang/Analysis/PathSensitive/Store.h
  vendor/clang/dist/include/clang/Analysis/Support/BumpVector.h
  vendor/clang/dist/include/clang/Basic/Diagnostic.h
  vendor/clang/dist/include/clang/Basic/DiagnosticParseKinds.td
  vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td
  vendor/clang/dist/include/clang/Basic/FileManager.h
  vendor/clang/dist/include/clang/Basic/IdentifierTable.h
  vendor/clang/dist/include/clang/Basic/OnDiskHashTable.h
  vendor/clang/dist/include/clang/Basic/SourceManager.h
  vendor/clang/dist/include/clang/Basic/TargetInfo.h
  vendor/clang/dist/include/clang/Frontend/ASTUnit.h
  vendor/clang/dist/include/clang/Frontend/PCHBitCodes.h
  vendor/clang/dist/include/clang/Frontend/PCHReader.h
  vendor/clang/dist/include/clang/Frontend/PCHWriter.h
  vendor/clang/dist/include/clang/Index/ASTLocation.h
  vendor/clang/dist/include/clang/Index/Indexer.h
  vendor/clang/dist/include/clang/Index/Utils.h
  vendor/clang/dist/include/clang/Parse/Action.h
  vendor/clang/dist/lib/AST/ASTContext.cpp
  vendor/clang/dist/lib/AST/CXXInheritance.cpp
  vendor/clang/dist/lib/AST/Decl.cpp
  vendor/clang/dist/lib/AST/DeclTemplate.cpp
  vendor/clang/dist/lib/AST/DeclarationName.cpp
  vendor/clang/dist/lib/AST/Expr.cpp
  vendor/clang/dist/lib/AST/Stmt.cpp
  vendor/clang/dist/lib/AST/StmtDumper.cpp
  vendor/clang/dist/lib/AST/StmtPrinter.cpp
  vendor/clang/dist/lib/AST/Type.cpp
  vendor/clang/dist/lib/AST/TypeLoc.cpp
  vendor/clang/dist/lib/Analysis/AnalysisContext.cpp
  vendor/clang/dist/lib/Analysis/BasicObjCFoundationChecks.cpp
  vendor/clang/dist/lib/Analysis/BasicStore.cpp
  vendor/clang/dist/lib/Analysis/CFG.cpp
  vendor/clang/dist/lib/Analysis/CFRefCount.cpp
  vendor/clang/dist/lib/Analysis/GRExprEngine.cpp
  vendor/clang/dist/lib/Analysis/GRExprEngineInternalChecks.cpp
  vendor/clang/dist/lib/Analysis/LiveVariables.cpp
  vendor/clang/dist/lib/Analysis/RegionStore.cpp
  vendor/clang/dist/lib/Analysis/SimpleSValuator.cpp
  vendor/clang/dist/lib/Basic/Diagnostic.cpp
  vendor/clang/dist/lib/Basic/FileManager.cpp
  vendor/clang/dist/lib/Basic/IdentifierTable.cpp
  vendor/clang/dist/lib/Basic/TargetInfo.cpp
  vendor/clang/dist/lib/Basic/Targets.cpp
  vendor/clang/dist/lib/CodeGen/CGBlocks.cpp
  vendor/clang/dist/lib/CodeGen/CGBlocks.h
  vendor/clang/dist/lib/CodeGen/CGCXX.cpp
  vendor/clang/dist/lib/CodeGen/CGCall.cpp
  vendor/clang/dist/lib/CodeGen/CGDebugInfo.cpp
  vendor/clang/dist/lib/CodeGen/CGDebugInfo.h
  vendor/clang/dist/lib/CodeGen/CGDecl.cpp
  vendor/clang/dist/lib/CodeGen/CGExpr.cpp
  vendor/clang/dist/lib/CodeGen/CGExprAgg.cpp
  vendor/clang/dist/lib/CodeGen/CGExprConstant.cpp
  vendor/clang/dist/lib/CodeGen/CGExprScalar.cpp
  

svn commit: r198399 - vendor/clang/clang-r84949

2009-10-23 Thread Roman Divacky
Author: rdivacky
Date: Fri Oct 23 14:22:51 2009
New Revision: 198399
URL: http://svn.freebsd.org/changeset/base/198399

Log:
  Tag clang r84949.

Added:
  vendor/clang/clang-r84949/
 - copied from r198398, vendor/clang/dist/
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198400 - head/sys/powerpc/aim

2009-10-23 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct 23 14:27:40 2009
New Revision: 198400
URL: http://svn.freebsd.org/changeset/base/198400

Log:
  Do not map the trap vectors into the kernel's address space. They are
  only used in real mode and keeping them mapped only serves to make NULL
  a valid address, which results in silent NULL pointer deferences.
  
  Suggested by:   Patrick Kerharo
  Obtained from:projects/ppc64

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/trap_subr.S

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cFri Oct 23 14:22:51 2009
(r198399)
+++ head/sys/powerpc/aim/mmu_oea64.cFri Oct 23 14:27:40 2009
(r198400)
@@ -868,15 +868,17 @@ moea64_bridge_bootstrap(mmu_t mmup, vm_o
ENABLE_TRANS(msr);
 
/*
-* Map certain important things, like ourselves and the exception
-* vectors
+* Map certain important things, like ourselves.
+*
+* NOTE: We do not map the exception vector space. That code is
+* used only in real mode, and leaving it unmapped allows us to
+* catch NULL pointer deferences, instead of making NULL a valid
+* address.
 */
 
DISABLE_TRANS(msr);
for (pa = kernelstart  ~PAGE_MASK; pa  kernelend; pa += PAGE_SIZE) 
moea64_kenter(mmup, pa, pa);
-   for (pa = EXC_RSVD; pa  EXC_LAST; pa += PAGE_SIZE) 
-   moea64_kenter(mmup, pa, pa);
ENABLE_TRANS(msr);
 
if (!ofw_real_mode) {

Modified: head/sys/powerpc/aim/trap_subr.S
==
--- head/sys/powerpc/aim/trap_subr.SFri Oct 23 14:22:51 2009
(r198399)
+++ head/sys/powerpc/aim/trap_subr.SFri Oct 23 14:27:40 2009
(r198400)
@@ -275,10 +275,16 @@ CNAME(restorebridgesize) = .-CNAME(resto
 /*
  * Processor reset exception handler. These are typically
  * the first instructions the processor executes after a
- * software reset.
+ * software reset. We do this in two bits so that we are
+ * not still hanging around in the trap handling region
+ * once the MMU is turned on.
  */
.globl  CNAME(rstcode), CNAME(rstsize)
 CNAME(rstcode):
+   ba  cpu_reset
+CNAME(rstsize) = . - CNAME(rstcode)
+
+cpu_reset:
bl  1f
 
.space  124
@@ -296,7 +302,6 @@ CNAME(rstcode):
/* Should not be reached */
 9:
b   9b
-CNAME(rstsize) = . - CNAME(rstcode)
 #endif
 
 /*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198403 - in vendor/llvm/dist/include/llvm: Config Support

2009-10-23 Thread Roman Divacky
Author: rdivacky
Date: Fri Oct 23 14:36:14 2009
New Revision: 198403
URL: http://svn.freebsd.org/changeset/base/198403

Log:
  These files does not belong here.

Deleted:
  vendor/llvm/dist/include/llvm/Config/AsmParsers.def
  vendor/llvm/dist/include/llvm/Config/AsmPrinters.def
  vendor/llvm/dist/include/llvm/Config/Targets.def
  vendor/llvm/dist/include/llvm/Config/config.h
  vendor/llvm/dist/include/llvm/Support/DataTypes.h
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198405 - stable/8/sbin/dhclient

2009-10-23 Thread Philip Paeps
Author: philip
Date: Fri Oct 23 14:43:17 2009
New Revision: 198405
URL: http://svn.freebsd.org/changeset/base/198405

Log:
  MFC r198352
  
Make dhclient use bootpc (68) as the source port for unicast
DHCPREQUEST packets instead of allowing the protocol stack to pick
a random source port.
  
This fixes the behaviour where dhclient would never transition
from RENEWING to BOUND without going through REBINDING in networks
which are paranoid about DHCP spoofing, such as most mainstream
cable-broadband ISP networks.
  
  Obtained from:OpenBSD
  Reviewed by:  brooks
  Approved by:  re (kib)

Modified:
  stable/8/sbin/dhclient/   (props changed)
  stable/8/sbin/dhclient/bpf.c
  stable/8/sbin/dhclient/dhcpd.h
  stable/8/sbin/dhclient/packet.c

Modified: stable/8/sbin/dhclient/bpf.c
==
--- stable/8/sbin/dhclient/bpf.cFri Oct 23 14:40:38 2009
(r198404)
+++ stable/8/sbin/dhclient/bpf.cFri Oct 23 14:43:17 2009
(r198405)
@@ -90,11 +90,23 @@ if_register_bpf(struct interface_info *i
 void
 if_register_send(struct interface_info *info)
 {
+   int sock, on = 1;
+
/*
 * If we're using the bpf API for sending and receiving, we
 * don't need to register this interface twice.
 */
info-wfdesc = info-rfdesc;
+
+   /*
+* Use raw socket for unicast send.
+*/
+   if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP)) == -1)
+   error(socket(SOCK_RAW): %m);
+   if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, on,
+   sizeof(on)) == -1)
+   error(setsockopt(IP_HDRINCL): %m);
+   info-ufdesc = sock;
 }
 
 /*
@@ -244,35 +256,32 @@ send_packet(struct interface_info *inter
 {
unsigned char buf[256];
struct iovec iov[2];
+   struct msghdr msg;
int result, bufp = 0;
-   int sock;
-
-   if (to-sin_addr.s_addr != INADDR_BROADCAST) {
-   note(SENDING DIRECT);
-   /* We know who the server is, send the packet via
-  normal socket interface */
-
-   if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) = 0) {
-   result = sendto (sock, (char *)raw, len, 0,
-(struct sockaddr *)to, sizeof *to);
-   close(sock);
-   if (result  0)
-   return result;
-   }
-   }
 
/* Assemble the headers... */
-   assemble_hw_header(interface, buf, bufp, hto);
+   if (to-sin_addr.s_addr == INADDR_BROADCAST)
+   assemble_hw_header(interface, buf, bufp, hto);
assemble_udp_ip_header(buf, bufp, from.s_addr,
to-sin_addr.s_addr, to-sin_port, (unsigned char *)raw, len);
 
-   /* Fire it off */
iov[0].iov_base = (char *)buf;
iov[0].iov_len = bufp;
iov[1].iov_base = (char *)raw;
iov[1].iov_len = len;
 
-   result = writev(interface-wfdesc, iov, 2);
+   /* Fire it off */
+   if (to-sin_addr.s_addr == INADDR_BROADCAST)
+   result = writev(interface-wfdesc, iov, 2);
+   else {
+   memset(msg, 0, sizeof(msg));
+   msg.msg_name = (struct sockaddr *)to;
+   msg.msg_namelen = sizeof(*to);
+   msg.msg_iov = iov;
+   msg.msg_iovlen = 2;
+   result = sendmsg(interface-ufdesc, msg, 0);
+   }
+
if (result  0)
warning(send_packet: %m);
return (result);

Modified: stable/8/sbin/dhclient/dhcpd.h
==
--- stable/8/sbin/dhclient/dhcpd.h  Fri Oct 23 14:40:38 2009
(r198404)
+++ stable/8/sbin/dhclient/dhcpd.h  Fri Oct 23 14:43:17 2009
(r198405)
@@ -37,6 +37,8 @@
  * Enterprises.  To learn more about the Internet Software Consortium,
  * see ``http://www.vix.com/isc''.  To learn more about Vixie
  * Enterprises, see ``http://www.vix.com''.
+ *
+ * $FreeBSD$
  */
 
 #include sys/types.h
@@ -194,6 +196,7 @@ struct interface_info {
char name[IFNAMSIZ];
int  rfdesc;
int  wfdesc;
+   int  ufdesc;
unsigned char   *rbuf;
size_t   rbuf_max;
size_t   rbuf_offset;

Modified: stable/8/sbin/dhclient/packet.c
==
--- stable/8/sbin/dhclient/packet.c Fri Oct 23 14:40:38 2009
(r198404)
+++ stable/8/sbin/dhclient/packet.c Fri Oct 23 14:43:17 2009
(r198405)
@@ -135,6 +135,17 @@ assemble_udp_ip_header(unsigned char *bu
ip.ip_dst.s_addr = to;
 
ip.ip_sum = wrapsum(checksum((unsigned char *)ip, sizeof(ip), 0));
+
+   /*
+* 

svn commit: r198406 - in head: lib/libc/gen tools/regression/lib/libc/gen

2009-10-23 Thread Jilles Tjoelker
Author: jilles
Date: Fri Oct 23 14:50:11 2009
New Revision: 198406
URL: http://svn.freebsd.org/changeset/base/198406

Log:
  wordexp(3): fix some bugs with signals and long outputs
  * retry various system calls on EINTR
  * retry the rest after a short read (common if there is more than about 1K
of output)
  * block SIGCHLD like system(3) does (note that this does not and cannot
work fully in threaded programs, they will need to be careful with wait
functions)
  
  PR:   90580
  MFC after:1 month

Modified:
  head/lib/libc/gen/wordexp.c
  head/tools/regression/lib/libc/gen/test-wordexp.c

Modified: head/lib/libc/gen/wordexp.c
==
--- head/lib/libc/gen/wordexp.c Fri Oct 23 14:43:17 2009(r198405)
+++ head/lib/libc/gen/wordexp.c Fri Oct 23 14:50:11 2009(r198406)
@@ -28,8 +28,10 @@
 #include sys/cdefs.h
 #include sys/types.h
 #include sys/wait.h
+#include errno.h
 #include fcntl.h
 #include paths.h
+#include signal.h
 #include stdio.h
 #include stdlib.h
 #include string.h
@@ -73,6 +75,24 @@ wordexp(const char * __restrict words, w
return (0);
 }
 
+static size_t
+we_read_fully(int fd, char *buffer, size_t len)
+{
+   size_t done;
+   ssize_t nread;
+
+   done = 0;
+   do {
+   nread = _read(fd, buffer + done, len - done);
+   if (nread == -1  errno == EINTR)
+   continue;
+   if (nread = 0)
+   break;
+   done += nread;
+   } while (done != len);
+   return done;
+}
+
 /*
  * we_askshell --
  * Use the `wordexp' /bin/sh builtin function to do most of the work
@@ -90,20 +110,31 @@ we_askshell(const char *words, wordexp_t
size_t sofs;/* Offset into we-we_strings */
size_t vofs;/* Offset into we-we_wordv */
pid_t pid;  /* Process ID of child */
+   pid_t wpid; /* waitpid return value */
int status; /* Child exit status */
+   int error;  /* Our return value */
+   int serrno; /* errno to return */
char *ifs;  /* IFS env. var. */
char *np, *p;   /* Handy pointers */
char *nstrings; /* Temporary for realloc() */
char **nwv; /* Temporary for realloc() */
+   sigset_t newsigblock, oldsigblock;
 
+   serrno = errno;
if ((ifs = getenv(IFS)) == NULL)
ifs =  \t\n;
 
if (pipe(pdes)  0)
return (WRDE_NOSPACE);  /* XXX */
+   (void)sigemptyset(newsigblock);
+   (void)sigaddset(newsigblock, SIGCHLD);
+   (void)_sigprocmask(SIG_BLOCK, newsigblock, oldsigblock);
if ((pid = fork())  0) {
+   serrno = errno;
_close(pdes[0]);
_close(pdes[1]);
+   (void)_sigprocmask(SIG_SETMASK, oldsigblock, NULL);
+   errno = serrno;
return (WRDE_NOSPACE);  /* XXX */
}
else if (pid == 0) {
@@ -114,6 +145,7 @@ we_askshell(const char *words, wordexp_t
int devnull;
char *cmd;
 
+   (void)_sigprocmask(SIG_SETMASK, oldsigblock, NULL);
_close(pdes[0]);
if (_dup2(pdes[1], STDOUT_FILENO)  0)
_exit(1);
@@ -139,10 +171,11 @@ we_askshell(const char *words, wordexp_t
 * the expanded words separated by nulls.
 */
_close(pdes[1]);
-   if (_read(pdes[0], wbuf, 8) != 8 || _read(pdes[0], bbuf, 8) != 8) {
-   _close(pdes[0]);
-   _waitpid(pid, status, 0);
-   return (flags  WRDE_UNDEF ? WRDE_BADVAL : WRDE_SYNTAX);
+   if (we_read_fully(pdes[0], wbuf, 8) != 8 ||
+   we_read_fully(pdes[0], bbuf, 8) != 8) {
+   error = flags  WRDE_UNDEF ? WRDE_BADVAL : WRDE_SYNTAX;
+   serrno = errno;
+   goto cleanup;
}
wbuf[8] = bbuf[8] = '\0';
nwords = strtol(wbuf, NULL, 16);
@@ -162,33 +195,38 @@ we_askshell(const char *words, wordexp_t
if ((nwv = realloc(we-we_wordv, (we-we_wordc + 1 +
(flags  WRDE_DOOFFS ?  we-we_offs : 0)) *
sizeof(char *))) == NULL) {
-   _close(pdes[0]);
-   _waitpid(pid, status, 0);
-   return (WRDE_NOSPACE);
+   error = WRDE_NOSPACE;
+   goto cleanup;
}
we-we_wordv = nwv;
if ((nstrings = realloc(we-we_strings, we-we_nbytes)) == NULL) {
-   _close(pdes[0]);
-   _waitpid(pid, status, 0);
-   return (WRDE_NOSPACE);
+   error = WRDE_NOSPACE;
+   goto cleanup;
}
for (i = 0; i  vofs; i++)
if (we-we_wordv[i] != NULL)
 

svn commit: r198407 - head/sys/dev/ata

2009-10-23 Thread Alexander Motin
Author: mav
Date: Fri Oct 23 14:56:29 2009
New Revision: 198407
URL: http://svn.freebsd.org/changeset/base/198407

Log:
  MFp4:
  Do not differentiate 12/16 bytes ATAPI CCB formats when it is not needed.

Modified:
  head/sys/dev/ata/ata-queue.c
  head/sys/dev/ata/atapi-cd.c
  head/sys/dev/ata/atapi-fd.c
  head/sys/dev/ata/atapi-tape.c

Modified: head/sys/dev/ata/ata-queue.c
==
--- head/sys/dev/ata/ata-queue.cFri Oct 23 14:50:11 2009
(r198406)
+++ head/sys/dev/ata/ata-queue.cFri Oct 23 14:56:29 2009
(r198407)
@@ -150,15 +150,11 @@ ata_atapicmd(device_t dev, u_int8_t *ccb
 int count, int flags, int timeout)
 {
 struct ata_request *request = ata_alloc_request();
-struct ata_device *atadev = device_get_softc(dev);
 int error = ENOMEM;
 
 if (request) {
request-dev = dev;
-   if ((atadev-param.config  ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12)
-   bcopy(ccb, request-u.atapi.ccb, 12);
-   else
-   bcopy(ccb, request-u.atapi.ccb, 16);
+   bcopy(ccb, request-u.atapi.ccb, 16);
request-data = data;
request-bytecount = count;
request-transfersize = min(request-bytecount, 65534);

Modified: head/sys/dev/ata/atapi-cd.c
==
--- head/sys/dev/ata/atapi-cd.c Fri Oct 23 14:50:11 2009(r198406)
+++ head/sys/dev/ata/atapi-cd.c Fri Oct 23 14:56:29 2009(r198407)
@@ -863,9 +863,7 @@ acd_strategy(struct bio *bp)
 }
 request-dev = dev;
 request-bio = bp;
-bcopy(ccb, request-u.atapi.ccb,
- (atadev-param.config  ATA_PROTO_MASK) == 
- ATA_PROTO_ATAPI_12 ? 16 : 12);
+bcopy(ccb, request-u.atapi.ccb, 16);
 request-data = bp-bio_data;
 request-bytecount = count * blocksize;
 request-transfersize = min(request-bytecount, 65534);

Modified: head/sys/dev/ata/atapi-fd.c
==
--- head/sys/dev/ata/atapi-fd.c Fri Oct 23 14:50:11 2009(r198406)
+++ head/sys/dev/ata/atapi-fd.c Fri Oct 23 14:56:29 2009(r198407)
@@ -240,9 +240,7 @@ afd_strategy(struct bio *bp)
 }
 request-dev = dev;
 request-bio = bp;
-bcopy(ccb, request-u.atapi.ccb,
- (atadev-param.config  ATA_PROTO_MASK) == 
- ATA_PROTO_ATAPI_12 ? 16 : 12);
+bcopy(ccb, request-u.atapi.ccb, 16);
 request-data = bp-bio_data;
 request-bytecount = count * fdp-sectorsize;
 request-transfersize = min(request-bytecount, 65534);

Modified: head/sys/dev/ata/atapi-tape.c
==
--- head/sys/dev/ata/atapi-tape.c   Fri Oct 23 14:50:11 2009
(r198406)
+++ head/sys/dev/ata/atapi-tape.c   Fri Oct 23 14:56:29 2009
(r198407)
@@ -373,7 +373,6 @@ static void 
 ast_strategy(struct bio *bp)
 {
 device_t dev = bp-bio_dev-si_drv1;
-struct ata_device *atadev = device_get_softc(dev);
 struct ast_softc *stp = device_get_ivars(dev);
 struct ata_request *request;
 u_int32_t blkcount;
@@ -426,9 +425,7 @@ ast_strategy(struct bio *bp)
 }
 request-dev = dev;
 request-driver = bp;
-bcopy(ccb, request-u.atapi.ccb,
- (atadev-param.config  ATA_PROTO_MASK) == 
- ATA_PROTO_ATAPI_12 ? 16 : 12);
+bcopy(ccb, request-u.atapi.ccb, 16);
 request-data = bp-bio_data;
 request-bytecount = blkcount * stp-blksize;
 request-transfersize = min(request-bytecount, 65534);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198408 - head/sys/kern

2009-10-23 Thread John Baldwin
Author: jhb
Date: Fri Oct 23 15:09:51 2009
New Revision: 198408
URL: http://svn.freebsd.org/changeset/base/198408

Log:
  Don't bother copying the name of a kproc or kthread out into a temporary
  array just to pass that array to printf().  kproc and kthread names are
  NUL-terminated and can be printed using printf() directly.
  
  Reviewed by:  bde

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Fri Oct 23 14:56:29 2009
(r198407)
+++ head/sys/kern/kern_shutdown.c   Fri Oct 23 15:09:51 2009
(r198408)
@@ -618,16 +618,14 @@ void
 kproc_shutdown(void *arg, int howto)
 {
struct proc *p;
-   char procname[MAXCOMLEN + 1];
int error;
 
if (panicstr)
return;
 
p = (struct proc *)arg;
-   strlcpy(procname, p-p_comm, sizeof(procname));
printf(Waiting (max %d seconds) for system process `%s' to stop...,
-   kproc_shutdown_wait, procname);
+   kproc_shutdown_wait, p-p_comm);
error = kproc_suspend(p, kproc_shutdown_wait * hz);
 
if (error == EWOULDBLOCK)
@@ -640,16 +638,14 @@ void
 kthread_shutdown(void *arg, int howto)
 {
struct thread *td;
-   char procname[MAXCOMLEN + 1];
int error;
 
if (panicstr)
return;
 
td = (struct thread *)arg;
-   strlcpy(procname, td-td_name, sizeof(procname));
printf(Waiting (max %d seconds) for system thread `%s' to stop...,
-   kproc_shutdown_wait, procname);
+   kproc_shutdown_wait, td-td_name);
error = kthread_suspend(td, kproc_shutdown_wait * hz);
 
if (error == EWOULDBLOCK)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198409 - head/sys/sys

2009-10-23 Thread John Baldwin
Author: jhb
Date: Fri Oct 23 15:10:41 2009
New Revision: 198409
URL: http://svn.freebsd.org/changeset/base/198409

Log:
  Style fix.

Modified:
  head/sys/sys/ktrace.h

Modified: head/sys/sys/ktrace.h
==
--- head/sys/sys/ktrace.h   Fri Oct 23 15:09:51 2009(r198408)
+++ head/sys/sys/ktrace.h   Fri Oct 23 15:10:41 2009(r198409)
@@ -52,7 +52,7 @@ struct ktr_header {
int ktr_len;/* length of buf */
short   ktr_type;   /* trace record type */
pid_t   ktr_pid;/* process id */
-   charktr_comm[MAXCOMLEN+1];  /* command name */
+   charktr_comm[MAXCOMLEN + 1];/* command name */
struct  timeval ktr_time;   /* timestamp */
intptr_tktr_tid;/* was ktr_buffer */
 };
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198410 - stable/7/sbin/dhclient

2009-10-23 Thread Philip Paeps
Author: philip
Date: Fri Oct 23 15:12:05 2009
New Revision: 198410
URL: http://svn.freebsd.org/changeset/base/198410

Log:
  MFC r198352
  
Make dhclient use bootpc (68) as the source port for unicast
DHCPREQUEST packets instead of allowing the protocol stack to pick
a random source port.
  
This fixes the behaviour where dhclient would never transition
from RENEWING to BOUND without going through REBINDING in networks
which are paranoid about DHCP spoofing, such as most mainstream
cable-broadband ISP networks.
  
  Obtained from:OpenBSD
  Reviewed by:  brooks

Modified:
  stable/7/sbin/dhclient/   (props changed)
  stable/7/sbin/dhclient/bpf.c
  stable/7/sbin/dhclient/dhcpd.h
  stable/7/sbin/dhclient/packet.c

Modified: stable/7/sbin/dhclient/bpf.c
==
--- stable/7/sbin/dhclient/bpf.cFri Oct 23 15:10:41 2009
(r198409)
+++ stable/7/sbin/dhclient/bpf.cFri Oct 23 15:12:05 2009
(r198410)
@@ -90,11 +90,23 @@ if_register_bpf(struct interface_info *i
 void
 if_register_send(struct interface_info *info)
 {
+   int sock, on = 1;
+
/*
 * If we're using the bpf API for sending and receiving, we
 * don't need to register this interface twice.
 */
info-wfdesc = info-rfdesc;
+
+   /*
+* Use raw socket for unicast send.
+*/
+   if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP)) == -1)
+   error(socket(SOCK_RAW): %m);
+   if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, on,
+   sizeof(on)) == -1)
+   error(setsockopt(IP_HDRINCL): %m);
+   info-ufdesc = sock;
 }
 
 /*
@@ -244,35 +256,32 @@ send_packet(struct interface_info *inter
 {
unsigned char buf[256];
struct iovec iov[2];
+   struct msghdr msg;
int result, bufp = 0;
-   int sock;
-
-   if (to-sin_addr.s_addr != INADDR_BROADCAST) {
-   note(SENDING DIRECT);
-   /* We know who the server is, send the packet via
-  normal socket interface */
-
-   if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) = 0) {
-   result = sendto (sock, (char *)raw, len, 0,
-(struct sockaddr *)to, sizeof *to);
-   close(sock);
-   if (result  0)
-   return result;
-   }
-   }
 
/* Assemble the headers... */
-   assemble_hw_header(interface, buf, bufp, hto);
+   if (to-sin_addr.s_addr == INADDR_BROADCAST)
+   assemble_hw_header(interface, buf, bufp, hto);
assemble_udp_ip_header(buf, bufp, from.s_addr,
to-sin_addr.s_addr, to-sin_port, (unsigned char *)raw, len);
 
-   /* Fire it off */
iov[0].iov_base = (char *)buf;
iov[0].iov_len = bufp;
iov[1].iov_base = (char *)raw;
iov[1].iov_len = len;
 
-   result = writev(interface-wfdesc, iov, 2);
+   /* Fire it off */
+   if (to-sin_addr.s_addr == INADDR_BROADCAST)
+   result = writev(interface-wfdesc, iov, 2);
+   else {
+   memset(msg, 0, sizeof(msg));
+   msg.msg_name = (struct sockaddr *)to;
+   msg.msg_namelen = sizeof(*to);
+   msg.msg_iov = iov;
+   msg.msg_iovlen = 2;
+   result = sendmsg(interface-ufdesc, msg, 0);
+   }
+
if (result  0)
warning(send_packet: %m);
return (result);

Modified: stable/7/sbin/dhclient/dhcpd.h
==
--- stable/7/sbin/dhclient/dhcpd.h  Fri Oct 23 15:10:41 2009
(r198409)
+++ stable/7/sbin/dhclient/dhcpd.h  Fri Oct 23 15:12:05 2009
(r198410)
@@ -37,6 +37,8 @@
  * Enterprises.  To learn more about the Internet Software Consortium,
  * see ``http://www.vix.com/isc''.  To learn more about Vixie
  * Enterprises, see ``http://www.vix.com''.
+ *
+ * $FreeBSD$
  */
 
 #include sys/types.h
@@ -194,6 +196,7 @@ struct interface_info {
char name[IFNAMSIZ];
int  rfdesc;
int  wfdesc;
+   int  ufdesc;
unsigned char   *rbuf;
size_t   rbuf_max;
size_t   rbuf_offset;

Modified: stable/7/sbin/dhclient/packet.c
==
--- stable/7/sbin/dhclient/packet.c Fri Oct 23 15:10:41 2009
(r198409)
+++ stable/7/sbin/dhclient/packet.c Fri Oct 23 15:12:05 2009
(r198410)
@@ -135,6 +135,17 @@ assemble_udp_ip_header(unsigned char *bu
ip.ip_dst.s_addr = to;
 
ip.ip_sum = wrapsum(checksum((unsigned char *)ip, sizeof(ip), 0));
+
+   /*
+* While the BPF -- used for 

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

2009-10-23 Thread John Baldwin
Author: jhb
Date: Fri Oct 23 15:14:54 2009
New Revision: 198411
URL: http://svn.freebsd.org/changeset/base/198411

Log:
  - Fix several off-by-one errors when using MAXCOMLEN.  The p_comm[] and
td_name[] arrays are actually MAXCOMLEN + 1 in size and a few places that
created shadow copies of these arrays were just using MAXCOMLEN.
  - Prefer using sizeof() of an array type to explicit constants for the
array length in a few places.
  - Ensure that all of p_comm[] and td_name[] is always zero'd during
execve() to guard against any possible information leaks.  Previously
trailing garbage in p_comm[] could be leaked to userland in ktrace
record headers via td_name[].
  
  Reviewed by:  bde

Modified:
  head/sys/kern/kern_exec.c
  head/sys/kern/kern_ktrace.c
  head/sys/kern/subr_bus.c
  head/sys/kern/subr_taskqueue.c
  head/sys/sys/interrupt.h

Modified: head/sys/kern/kern_exec.c
==
--- head/sys/kern/kern_exec.c   Fri Oct 23 15:12:05 2009(r198410)
+++ head/sys/kern/kern_exec.c   Fri Oct 23 15:14:54 2009(r198411)
@@ -326,7 +326,7 @@ do_execve(td, args, mac_p)
struct ucred *newcred = NULL, *oldcred;
struct uidinfo *euip;
register_t *stack_base;
-   int error, len = 0, i;
+   int error, i;
struct image_params image_params, *imgp;
struct vattr attr;
int (*img_first)(struct image_params *);
@@ -602,18 +602,12 @@ interpret:
execsigs(p);
 
/* name this process - nameiexec(p, ndp) */
-   if (args-fname) {
-   len = min(nd.ni_cnd.cn_namelen,MAXCOMLEN);
-   bcopy(nd.ni_cnd.cn_nameptr, p-p_comm, len);
-   } else {
-   if (vn_commname(binvp, p-p_comm, MAXCOMLEN + 1) == 0)
-   len = MAXCOMLEN;
-   else {
-   len = sizeof(fexecv_proc_title);
-   bcopy(fexecv_proc_title, p-p_comm, len);
-   }
-   }
-   p-p_comm[len] = 0;
+   bzero(p-p_comm, sizeof(p-p_comm));
+   if (args-fname)
+   bcopy(nd.ni_cnd.cn_nameptr, p-p_comm,
+   min(nd.ni_cnd.cn_namelen, MAXCOMLEN));
+   else if (vn_commname(binvp, p-p_comm, sizeof(p-p_comm)) != 0)
+   bcopy(fexecv_proc_title, p-p_comm, sizeof(fexecv_proc_title));
bcopy(p-p_comm, td-td_name, sizeof(td-td_name));
 
/*

Modified: head/sys/kern/kern_ktrace.c
==
--- head/sys/kern/kern_ktrace.c Fri Oct 23 15:12:05 2009(r198410)
+++ head/sys/kern/kern_ktrace.c Fri Oct 23 15:14:54 2009(r198411)
@@ -256,6 +256,10 @@ ktrace_resize_pool(u_int newsize)
return (ktr_requestpool);
 }
 
+/* ktr_getrequest() assumes that ktr_comm[] is the same size as td_name[]. */
+CTASSERT(sizeof(((struct ktr_header *)NULL)-ktr_comm) ==
+(sizeof((struct thread *)NULL)-td_name));
+
 static struct ktr_request *
 ktr_getrequest(int type)
 {
@@ -283,7 +287,8 @@ ktr_getrequest(int type)
microtime(req-ktr_header.ktr_time);
req-ktr_header.ktr_pid = p-p_pid;
req-ktr_header.ktr_tid = td-td_tid;
-   bcopy(td-td_name, req-ktr_header.ktr_comm, MAXCOMLEN + 1);
+   bcopy(td-td_name, req-ktr_header.ktr_comm,
+   sizeof(req-ktr_header.ktr_comm));
req-ktr_buffer = NULL;
req-ktr_header.ktr_len = 0;
} else {

Modified: head/sys/kern/subr_bus.c
==
--- head/sys/kern/subr_bus.cFri Oct 23 15:12:05 2009(r198410)
+++ head/sys/kern/subr_bus.cFri Oct 23 15:14:54 2009(r198411)
@@ -3861,8 +3861,8 @@ int
 bus_describe_intr(device_t dev, struct resource *irq, void *cookie,
 const char *fmt, ...)
 {
-   char descr[MAXCOMLEN];
va_list ap;
+   char descr[MAXCOMLEN + 1];
 
if (dev-parent == NULL)
return (EINVAL);

Modified: head/sys/kern/subr_taskqueue.c
==
--- head/sys/kern/subr_taskqueue.c  Fri Oct 23 15:12:05 2009
(r198410)
+++ head/sys/kern/subr_taskqueue.c  Fri Oct 23 15:14:54 2009
(r198411)
@@ -301,7 +301,7 @@ taskqueue_start_threads(struct taskqueue
struct thread *td;
struct taskqueue *tq;
int i, error;
-   char ktname[MAXCOMLEN];
+   char ktname[MAXCOMLEN + 1];
 
if (count = 0)
return (EINVAL);
@@ -309,7 +309,7 @@ taskqueue_start_threads(struct taskqueue
tq = *tqp;
 
va_start(ap, name);
-   vsnprintf(ktname, MAXCOMLEN, name, ap);
+   vsnprintf(ktname, sizeof(ktname), name, ap);
va_end(ap);
 
tq-tq_threads = malloc(sizeof(struct thread *) * count, M_TASKQUEUE,

Modified: head/sys/sys/interrupt.h

svn commit: r198412 - stable/6/sbin/dhclient

2009-10-23 Thread Philip Paeps
Author: philip
Date: Fri Oct 23 15:42:23 2009
New Revision: 198412
URL: http://svn.freebsd.org/changeset/base/198412

Log:
  MFC r198352
  
Make dhclient use bootpc (68) as the source port for unicast
DHCPREQUEST packets instead of allowing the protocol stack to pick
a random source port.
  
This fixes the behaviour where dhclient would never transition
from RENEWING to BOUND without going through REBINDING in networks
which are paranoid about DHCP spoofing, such as most mainstream
cable-broadband ISP networks.
  
  Obtained from:OpenBSD
  Reviewed by:  brooks
  Approved by:  re (kib)

Modified:
  stable/6/sbin/dhclient/   (props changed)
  stable/6/sbin/dhclient/bpf.c
  stable/6/sbin/dhclient/dhcpd.h
  stable/6/sbin/dhclient/packet.c

Modified: stable/6/sbin/dhclient/bpf.c
==
--- stable/6/sbin/dhclient/bpf.cFri Oct 23 15:14:54 2009
(r198411)
+++ stable/6/sbin/dhclient/bpf.cFri Oct 23 15:42:23 2009
(r198412)
@@ -90,11 +90,23 @@ if_register_bpf(struct interface_info *i
 void
 if_register_send(struct interface_info *info)
 {
+   int sock, on = 1;
+
/*
 * If we're using the bpf API for sending and receiving, we
 * don't need to register this interface twice.
 */
info-wfdesc = info-rfdesc;
+
+   /*
+* Use raw socket for unicast send.
+*/
+   if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP)) == -1)
+   error(socket(SOCK_RAW): %m);
+   if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, on,
+   sizeof(on)) == -1)
+   error(setsockopt(IP_HDRINCL): %m);
+   info-ufdesc = sock;
 }
 
 /*
@@ -244,35 +256,32 @@ send_packet(struct interface_info *inter
 {
unsigned char buf[256];
struct iovec iov[2];
+   struct msghdr msg;
int result, bufp = 0;
-   int sock;
-
-   if (to-sin_addr.s_addr != INADDR_BROADCAST) {
-   note(SENDING DIRECT);
-   /* We know who the server is, send the packet via
-  normal socket interface */
-
-   if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) = 0) {
-   result = sendto (sock, (char *)raw, len, 0,
-(struct sockaddr *)to, sizeof *to);
-   close(sock);
-   if (result  0)
-   return result;
-   }
-   }
 
/* Assemble the headers... */
-   assemble_hw_header(interface, buf, bufp, hto);
+   if (to-sin_addr.s_addr == INADDR_BROADCAST)
+   assemble_hw_header(interface, buf, bufp, hto);
assemble_udp_ip_header(buf, bufp, from.s_addr,
to-sin_addr.s_addr, to-sin_port, (unsigned char *)raw, len);
 
-   /* Fire it off */
iov[0].iov_base = (char *)buf;
iov[0].iov_len = bufp;
iov[1].iov_base = (char *)raw;
iov[1].iov_len = len;
 
-   result = writev(interface-wfdesc, iov, 2);
+   /* Fire it off */
+   if (to-sin_addr.s_addr == INADDR_BROADCAST)
+   result = writev(interface-wfdesc, iov, 2);
+   else {
+   memset(msg, 0, sizeof(msg));
+   msg.msg_name = (struct sockaddr *)to;
+   msg.msg_namelen = sizeof(*to);
+   msg.msg_iov = iov;
+   msg.msg_iovlen = 2;
+   result = sendmsg(interface-ufdesc, msg, 0);
+   }
+
if (result  0)
warning(send_packet: %m);
return (result);

Modified: stable/6/sbin/dhclient/dhcpd.h
==
--- stable/6/sbin/dhclient/dhcpd.h  Fri Oct 23 15:14:54 2009
(r198411)
+++ stable/6/sbin/dhclient/dhcpd.h  Fri Oct 23 15:42:23 2009
(r198412)
@@ -37,6 +37,8 @@
  * Enterprises.  To learn more about the Internet Software Consortium,
  * see ``http://www.vix.com/isc''.  To learn more about Vixie
  * Enterprises, see ``http://www.vix.com''.
+ *
+ * $FreeBSD$
  */
 
 #include sys/types.h
@@ -194,6 +196,7 @@ struct interface_info {
char name[IFNAMSIZ];
int  rfdesc;
int  wfdesc;
+   int  ufdesc;
unsigned char   *rbuf;
size_t   rbuf_max;
size_t   rbuf_offset;

Modified: stable/6/sbin/dhclient/packet.c
==
--- stable/6/sbin/dhclient/packet.c Fri Oct 23 15:14:54 2009
(r198411)
+++ stable/6/sbin/dhclient/packet.c Fri Oct 23 15:42:23 2009
(r198412)
@@ -135,6 +135,17 @@ assemble_udp_ip_header(unsigned char *bu
ip.ip_dst.s_addr = to;
 
ip.ip_sum = wrapsum(checksum((unsigned char *)ip, sizeof(ip), 0));
+
+   /*
+* 

svn commit: r198413 - vendor/llvm/dist/lib/Transforms/IPO

2009-10-23 Thread Roman Divacky
Author: rdivacky
Date: Fri Oct 23 15:58:05 2009
New Revision: 198413
URL: http://svn.freebsd.org/changeset/base/198413

Log:
  This was removed upstream.

Deleted:
  vendor/llvm/dist/lib/Transforms/IPO/IndMemRemoval.cpp
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198417 - head/sys/net

2009-10-23 Thread Robert Watson
Author: rwatson
Date: Fri Oct 23 17:26:29 2009
New Revision: 198417
URL: http://svn.freebsd.org/changeset/base/198417

Log:
  Remove unneeded blank line from bpf_drvinit().
  
  MFC after:3 days

Modified:
  head/sys/net/bpf.c

Modified: head/sys/net/bpf.c
==
--- head/sys/net/bpf.c  Fri Oct 23 17:02:37 2009(r198416)
+++ head/sys/net/bpf.c  Fri Oct 23 17:26:29 2009(r198417)
@@ -2038,7 +2038,6 @@ bpf_drvinit(void *unused)
dev = make_dev(bpf_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, bpf);
/* For compatibility */
make_dev_alias(dev, bpf0);
-
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198418 - in head/sys: netinet netinet6

2009-10-23 Thread Qing Li
Author: qingli
Date: Fri Oct 23 18:27:34 2009
New Revision: 198418
URL: http://svn.freebsd.org/changeset/base/198418

Log:
  Use the correct option name in the preprocessor command to enable
  or disable diagnostic messages.
  
  Reviewed by:  ru
  MFC after:3 days

Modified:
  head/sys/netinet/if_ether.c
  head/sys/netinet/in.c
  head/sys/netinet6/in6.c

Modified: head/sys/netinet/if_ether.c
==
--- head/sys/netinet/if_ether.c Fri Oct 23 17:26:29 2009(r198417)
+++ head/sys/netinet/if_ether.c Fri Oct 23 18:27:34 2009(r198418)
@@ -180,7 +180,7 @@ arptimer(void *arg)
(void) llentry_free(lle);
ARPSTAT_INC(timeouts);
} 
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
else {
struct sockaddr *l3addr = L3_ADDR(lle);
log(LOG_INFO, arptimer issue: %p, IPv4 address: \%s\\n, lle,

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Fri Oct 23 17:26:29 2009(r198417)
+++ head/sys/netinet/in.c   Fri Oct 23 18:27:34 2009(r198418)
@@ -1327,7 +1327,7 @@ in_lltable_rtcheck(struct ifnet *ifp, co
/* XXX rtalloc1 should take a const param */
rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0);
if (rt == NULL || (rt-rt_flags  RTF_GATEWAY) || rt-rt_ifp != ifp) {
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
log(LOG_INFO, IPv4 address: \%s\ is not on the network\n,
inet_ntoa(((const struct sockaddr_in *)l3addr)-sin_addr));
 #endif
@@ -1366,7 +1366,7 @@ in_lltable_lookup(struct lltable *llt, u
break;
}
if (lle == NULL) {
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
if (flags  LLE_DELETE)
log(LOG_INFO, interface address is missing from cache 
= %p  in delete\n, lle);
 #endif
@@ -1401,7 +1401,7 @@ in_lltable_lookup(struct lltable *llt, u
lle-la_flags = LLE_DELETED;
EVENTHANDLER_INVOKE(arp_update_event, lle);
LLE_WUNLOCK(lle);
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
log(LOG_INFO, ifaddr cache = %p  is deleted\n, lle);  
 #endif
}

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Fri Oct 23 17:26:29 2009(r198417)
+++ head/sys/netinet6/in6.c Fri Oct 23 18:27:34 2009(r198418)
@@ -2437,7 +2437,7 @@ in6_lltable_lookup(struct lltable *llt, 
LLE_WLOCK(lle);
lle-la_flags = LLE_DELETED;
LLE_WUNLOCK(lle);
-#ifdef DIAGNOSTICS
+#ifdef DIAGNOSTIC
log(LOG_INFO, ifaddr cache = %p  is deleted\n, lle);  
 #endif 
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198419 - head/sys/dev/fb

2009-10-23 Thread Jung-uk Kim
Author: jkim
Date: Fri Oct 23 18:41:00 2009
New Revision: 198419
URL: http://svn.freebsd.org/changeset/base/198419

Log:
  - When we restore VESA state, try BIOS POST earlier.  VESA restore state
  function may not work properly if we don't.  Turn off hardware cursor as
  vesa_set_mode() does.
  - Add VBE 3.0 specific fields in VESA mode structure and pack it.  Note
  the padding is 190 bytes although VBE 3.0 says 189 bytes.  It must be wrong
  because the size of structure becomes 255 bytes and the specification says
  it must be 256 bytes in total.  In fact, an example code in the spec. does
  it right, though.  While we are at it, fix some i386-isms.
  - Remove state buffer size limitation.  It is no longer necessary since
  sys/compat/x86bios/x86bios.c r198251.
  - Move int 0x10 vector test into vesa_bios_post() as we always do it anyway.

Modified:
  head/sys/dev/fb/vesa.c
  head/sys/dev/fb/vesa.h

Modified: head/sys/dev/fb/vesa.c
==
--- head/sys/dev/fb/vesa.c  Fri Oct 23 18:27:34 2009(r198418)
+++ head/sys/dev/fb/vesa.c  Fri Oct 23 18:41:00 2009(r198419)
@@ -74,8 +74,7 @@ typedef struct adp_state adp_state_t;
 
 /* VESA video adapter */
 static video_adapter_t *vesa_adp = NULL;
-static int vesa_state_buf_size = 0;
-#define VESA_BIOS_BUFSIZE  (3 * PAGE_SIZE)
+static ssize_t vesa_state_buf_size = -1;
 
 /* VESA functions */
 #if 0
@@ -188,7 +187,7 @@ static int vesa_bios_load_palette2(int s
 #define STATE_REG  (13)
 #define STATE_MOST (STATE_HW | STATE_DATA | STATE_REG)
 #define STATE_ALL  (STATE_HW | STATE_DATA | STATE_DAC | STATE_REG)
-static int vesa_bios_state_buf_size(void);
+static ssize_t vesa_bios_state_buf_size(void);
 static int vesa_bios_save_restore(int code, void *p, size_t size);
 static int vesa_bios_get_line_length(void);
 static int vesa_bios_set_line_length(int pixel, int *bytes, int *lines);
@@ -282,6 +281,10 @@ vesa_bios_post(void)
}
regs.R_DL = 0x80;
x86bios_call(regs, 0xc000, 0x0003);
+
+   if (x86bios_get_intr(0x10) == 0)
+   return (1);
+
return (0);
 }
 
@@ -532,7 +535,7 @@ vesa_bios_load_palette2(int start, int c
 }
 #endif
 
-static int
+static ssize_t
 vesa_bios_state_buf_size(void)
 {
x86regs_t regs;
@@ -557,9 +560,6 @@ vesa_bios_save_restore(int code, void *p
uint32_t offs;
void *buf;
 
-   if (size  VESA_BIOS_BUFSIZE)
-   return (1);
-
if (code != STATE_SAVE  code != STATE_LOAD)
return (1);
 
@@ -808,12 +808,11 @@ vesa_bios_init(void)
if (x86bios_get_intr(0x10) == 0) {
if (vesa_bios_post() != 0)
return (1);
-   offs = x86bios_get_intr(0x10);
-   if (offs == 0)
-   return (1);
-   if (bootverbose)
+   if (bootverbose) {
+   offs = x86bios_get_intr(0x10);
printf(VESA: interrupt vector installed (0x%x)\n,
BIOS_SADDRTOLADDR(offs));
+   }
}
 
x86bios_init_regs(regs);
@@ -879,6 +878,22 @@ vesa_bios_init(void)
if (vesa_bios_get_mode(vesa_vmodetab[i], vmode))
continue;
 
+   vmode.v_modeattr = le16toh(vmode.v_modeattr);
+   vmode.v_wgran = le16toh(vmode.v_wgran);
+   vmode.v_wsize = le16toh(vmode.v_wsize);
+   vmode.v_waseg = le16toh(vmode.v_waseg);
+   vmode.v_wbseg = le16toh(vmode.v_wbseg);
+   vmode.v_posfunc = le32toh(vmode.v_posfunc);
+   vmode.v_bpscanline = le16toh(vmode.v_bpscanline);
+   vmode.v_width = le16toh(vmode.v_width);
+   vmode.v_height = le16toh(vmode.v_height);
+   vmode.v_lfb = le32toh(vmode.v_lfb);
+   vmode.v_offscreen = le32toh(vmode.v_offscreen);
+   vmode.v_offscreensize = le16toh(vmode.v_offscreensize);
+   vmode.v_maxpixelclock = le32toh(vmode.v_maxpixelclock);
+   vmode.v_linbpscanline = le16toh(vmode.v_linbpscanline);
+   vmode.v_maxpixelclock = le32toh(vmode.v_maxpixelclock);
+
/* reject unsupported modes */
 #if 0
if ((vmode.v_modeattr  (V_MODESUPP | V_MODEOPTINFO 
@@ -1417,11 +1432,14 @@ vesa_save_state(video_adapter_t *adp, vo
if (adp != vesa_adp)
return ((*prevvidsw-save_state)(adp, p, size));
 
-   if (vesa_state_buf_size == 0)
+   if (vesa_state_buf_size == -1) {
vesa_state_buf_size = vesa_bios_state_buf_size();
+   if (vesa_state_buf_size == 0)
+   return (1);
+   }
if (size == 0)
-   return (sizeof(int) + vesa_state_buf_size);
-   else if (size  (sizeof(int) + vesa_state_buf_size))
+   return (offsetof(adp_state_t, regs) + 

svn commit: r198420 - in head/sys: boot/i386/zfsboot boot/zfs cddl/boot/zfs

2009-10-23 Thread Robert Noland
Author: rnoland
Date: Fri Oct 23 18:44:53 2009
New Revision: 198420
URL: http://svn.freebsd.org/changeset/base/198420

Log:
  Correct some issues with zfs boot.
  
   - Teach it to read gang blocks. (essentially untested)
 If you see ZFS: gang block detected!, please let
 me know, so we can either remove the printf if it
 works, or fix it if it doesn't.
  
   - If multiple partitions exist on a disk, probe them all.
 We also need to reset dsk-start to 0 to read the right
 sector here.
  
   - With GPT, we can have 128 partitions.
  
   - If the bootfs property has ever been set on a pool
 it seems that it never goes away.  zpool won't allow
 you to add to the pool with the bootfs property set.
 However, if you clear the property back to default
 we end up getting 0 for the object number and read
 a bogus block pointer and fail to boot.
  
   - Fix some error printfs. The printf in the loader is
 only capable of c,s and u formats.
  
   - Teach printf how to display %llu
  
  Reviewed by:  dfr, jhb
  MFC after:2 weeks

Modified:
  head/sys/boot/i386/zfsboot/zfsboot.c
  head/sys/boot/zfs/zfs.c
  head/sys/boot/zfs/zfsimpl.c
  head/sys/cddl/boot/zfs/zfsimpl.h

Modified: head/sys/boot/i386/zfsboot/zfsboot.c
==
--- head/sys/boot/i386/zfsboot/zfsboot.cFri Oct 23 18:41:00 2009
(r198419)
+++ head/sys/boot/i386/zfsboot/zfsboot.cFri Oct 23 18:44:53 2009
(r198420)
@@ -474,6 +474,7 @@ probe_drive(struct dsk *dsk, spa_t **spa
 slba = hdr.hdr_lba_table;
 elba = slba + hdr.hdr_entries / entries_per_sec;
 while (slba  elba) {
+   dsk-start = 0;
if (drvread(dsk, sec, slba, 1))
return;
for (part = 0; part  entries_per_sec; part++) {
@@ -494,7 +495,6 @@ probe_drive(struct dsk *dsk, spa_t **spa
 */
dsk = copy_dsk(dsk);
}
-   break;
}
}
slba++;
@@ -857,12 +857,13 @@ static void
 printf(const char *fmt,...)
 {
 va_list ap;
-char buf[10];
+char buf[20];
 char *s;
-unsigned u;
+unsigned long long u;
 int c;
 int minus;
 int prec;
+int l;
 int len;
 int pad;
 
@@ -871,6 +872,7 @@ printf(const char *fmt,...)
if (c == '%') {
minus = 0;
prec = 0;
+   l = 0;
nextfmt:
c = *fmt++;
switch (c) {
@@ -892,6 +894,9 @@ printf(const char *fmt,...)
case 'c':
putchar(va_arg(ap, int));
continue;
+   case 'l':
+   l++;
+   goto nextfmt;
case 's':
s = va_arg(ap, char *);
if (prec) {
@@ -914,7 +919,17 @@ printf(const char *fmt,...)
}
continue;
case 'u':
-   u = va_arg(ap, unsigned);
+   switch (l) {
+   case 2:
+   u = va_arg(ap, unsigned long long);
+   break;
+   case 1:
+   u = va_arg(ap, unsigned long);
+   break;
+   default:
+   u = va_arg(ap, unsigned);
+   break;
+   }
s = buf;
do
*s++ = '0' + u % 10U;

Modified: head/sys/boot/zfs/zfs.c
==
--- head/sys/boot/zfs/zfs.c Fri Oct 23 18:41:00 2009(r198419)
+++ head/sys/boot/zfs/zfs.c Fri Oct 23 18:44:53 2009(r198420)
@@ -100,7 +100,7 @@ zfs_open(const char *upath, struct open_
f-f_fsdata = (void *)fp;
 
if (spa-spa_root_objset.os_type != DMU_OST_ZFS) {
-   printf(Unexpected object set type %lld\n,
+   printf(Unexpected object set type %llu\n,
spa-spa_root_objset.os_type);
rc = EIO;
goto out;
@@ -413,7 +413,7 @@ zfs_dev_init(void) 
if (vdev_probe(vdev_read, (void*) (uintptr_t) fd, 0))
close(fd);
 
-   for (slice = 1; slice = 4; slice++) {
+   for (slice = 1; slice = 128; slice++) {
sprintf(devname, disk%dp%d:, unit, slice);
fd = open(devname, O_RDONLY);
if (fd == -1) {

Modified: head/sys/boot/zfs/zfsimpl.c
==
--- head/sys/boot/zfs/zfsimpl.c Fri Oct 23 18:41:00 2009(r198419)
+++ head/sys/boot/zfs/zfsimpl.c Fri Oct 23 18:44:53 2009(r198420)
@@ -53,6 +53,8 @@ static char *zfs_temp_buf, *zfs_temp_end
 
 #define TEMP_SIZE  (1*SPA_MAXBLOCKSIZE)
 
+static int zio_read(spa_t *spa, const blkptr_t *bp, void *buf);
+
 static void
 zfs_init(void)
 {
@@ -897,6 +899,33 @@ ilog2(int n)
 }
 
 static int

svn commit: r198421 - head/sys/dev/syscons

2009-10-23 Thread Jung-uk Kim
Author: jkim
Date: Fri Oct 23 18:53:21 2009
New Revision: 198421
URL: http://svn.freebsd.org/changeset/base/198421

Log:
  Search for default 800x600 graphics mode from supported VESA mode list.
  Many video controllers do not support 800x600x24 mode any more.

Modified:
  head/sys/dev/syscons/syscons.c

Modified: head/sys/dev/syscons/syscons.c
==
--- head/sys/dev/syscons/syscons.c  Fri Oct 23 18:44:53 2009
(r198420)
+++ head/sys/dev/syscons/syscons.c  Fri Oct 23 18:53:21 2009
(r198421)
@@ -343,17 +343,46 @@ sc_alloc_tty(int index, int devnum)
return (tp);
 }
 
+#ifdef SC_PIXEL_MODE
+static int
+sc_initial_mode(video_adapter_t *adp, int unit)
+{
+   video_info_t info;
+   int depth, vmode;
+   int i;
+
+   vmode = 0;
+   (void)resource_int_value(sc, unit, vesa_mode, vmode);
+   if (vmode  M_VESA_BASE || vmode  M_VESA_MODE_MAX)
+   vmode = 0;
+
+   /*
+* If the default mode is not supported, search for an available
+* 800x600 graphics mode with the highest color depth.
+*/
+   if (vmode == 0 || vidd_get_info(adp, vmode, info) != 0) {
+   depth = vmode = 0;
+   for (i = M_VESA_BASE; i = M_VESA_MODE_MAX; i++)
+   if (vidd_get_info(adp, i, info) == 0 
+   (info.vi_flags  V_INFO_GRAPHICS) != 0 
+   info.vi_width == 800  info.vi_height == 600 
+   info.vi_depth  depth) {
+   vmode = i;
+   depth = info.vi_depth;
+   }
+   }
+
+   return (vmode);
+}
+#endif
+
 int
 sc_attach_unit(int unit, int flags)
 {
 sc_softc_t *sc;
 scr_stat *scp;
-#ifdef SC_PIXEL_MODE
-video_info_t info;
-#endif
 int vc;
 struct cdev *dev;
-unsigned int vmode = 0;
 
 flags = ~SC_KERNEL_CONSOLE;
 
@@ -374,25 +403,24 @@ sc_attach_unit(int unit, int flags)
 if (sc_console == NULL)/* sc_console_unit  0 */
sc_console = scp;
 
-(void)resource_int_value(sc, unit, vesa_mode, vmode);
-if (vmode  M_VESA_BASE || vmode  M_VESA_MODE_MAX)
-   vmode = M_VESA_FULL_800;
-
 #ifdef SC_PIXEL_MODE
-if ((sc-config  SC_VESAMODE)
-(vidd_get_info(sc-adp, vmode, info) == 0)) {
+if ((sc-config  SC_VESAMODE) != 0) {
+   int vmode;
+   vmode = sc_initial_mode(sc-adp, unit);
+   if (vmode = M_VESA_BASE) {
 #ifdef DEV_SPLASH
-   if (sc-flags  SC_SPLASH_SCRN)
-   splash_term(sc-adp);
+   if (sc-flags  SC_SPLASH_SCRN)
+   splash_term(sc-adp);
 #endif
-   sc_set_graphics_mode(scp, NULL, vmode);
-   sc_set_pixel_mode(scp, NULL, 0, 0, 16, 8);
-   sc-initial_mode = vmode;
+   sc_set_graphics_mode(scp, NULL, vmode);
+   sc_set_pixel_mode(scp, NULL, 0, 0, 16, 8);
+   sc-initial_mode = vmode;
 #ifdef DEV_SPLASH
-   /* put up the splash again! */
-   if (sc-flags  SC_SPLASH_SCRN)
-   splash_init(sc-adp, scsplash_callback, sc);
+   /* put up the splash again! */
+   if (sc-flags  SC_SPLASH_SCRN)
+   splash_init(sc-adp, scsplash_callback, sc);
 #endif
+   }
 }
 #endif /* SC_PIXEL_MODE */
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198422 - head/sys/amd64/acpica

2009-10-23 Thread Jung-uk Kim
Author: jkim
Date: Fri Oct 23 18:57:52 2009
New Revision: 198422
URL: http://svn.freebsd.org/changeset/base/198422

Log:
  Try hiding annoying text cursor after the video controller is reset.

Modified:
  head/sys/amd64/acpica/acpi_wakecode.S

Modified: head/sys/amd64/acpica/acpi_wakecode.S
==
--- head/sys/amd64/acpica/acpi_wakecode.S   Fri Oct 23 18:53:21 2009
(r198421)
+++ head/sys/amd64/acpica/acpi_wakecode.S   Fri Oct 23 18:57:52 2009
(r198422)
@@ -88,6 +88,11 @@ wakeup_start:
movb$0, reset_video - wakeup_start
lcall   $0xc000, $3
 
+   /* When we reach here, int 0x10 should be ready.  Hide cursor. */
+   movb$0x01, %ah
+   movb$0x20, %ch
+   int $0x10
+
/* Re-start in case the previous BIOS call clobbers them. */
jmp wakeup_start
 1:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198423 - head/sys/dev/fb

2009-10-23 Thread Jung-uk Kim
Author: jkim
Date: Fri Oct 23 19:02:53 2009
New Revision: 198423
URL: http://svn.freebsd.org/changeset/base/198423

Log:
  Remove a redundant byte swapping in the previous commit.

Modified:
  head/sys/dev/fb/vesa.c

Modified: head/sys/dev/fb/vesa.c
==
--- head/sys/dev/fb/vesa.c  Fri Oct 23 18:57:52 2009(r198422)
+++ head/sys/dev/fb/vesa.c  Fri Oct 23 19:02:53 2009(r198423)
@@ -890,7 +890,6 @@ vesa_bios_init(void)
vmode.v_lfb = le32toh(vmode.v_lfb);
vmode.v_offscreen = le32toh(vmode.v_offscreen);
vmode.v_offscreensize = le16toh(vmode.v_offscreensize);
-   vmode.v_maxpixelclock = le32toh(vmode.v_maxpixelclock);
vmode.v_linbpscanline = le16toh(vmode.v_linbpscanline);
vmode.v_maxpixelclock = le32toh(vmode.v_maxpixelclock);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198424 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci nfsclient

2009-10-23 Thread John Baldwin
Author: jhb
Date: Fri Oct 23 19:52:29 2009
New Revision: 198424
URL: http://svn.freebsd.org/changeset/base/198424

Log:
  MFC 198174:
  Close a race with caching of -ve name lookups in the NFS client.
  Specifically, clients only trust -ve cache entries while the directory
  remains unchanged and discard any -ve cache entries for a directory when
  they notice that the modification time of a directory entry changes.  The
  race involves two concurrent lookups as follows:
  - Thread A does a lookup for file 'foo' which sends a lookup RPC to the
server.  The lookup fails and the server replies.
  - The 'foo' file is created (either by the same client or a different
client) updating the modification time on the parent directory of 'foo'.
  - Thread B does a lookup for a different file 'bar' which updates the
cached attributes of the parent directory of 'foo' to reflect the new
modification time after 'foo' was created.
  - Thread A finally resumes execution to parse the reply from the NFS
server.  It adds a -ve cache entry and sets the cached value of the
directory's modification time that is used for invalidating -ve cached
lookups to the new modification time set by thread B.
  
  At this point, future lookups of 'foo' will honor the -ve cached entry
  until the cached entry is pushed out of the name cache's LRU or the
  modification time of the parent directory is changed again by some other
  change.  The fix is to read the directory's modification time before
  sending the lookup RPC and use that cached modification time when setting
  the directory's cached modification time.  Also, we do not add a -ve cache
  entry if another thread has added -ve cache entry that set the directory's
  cached modification time to a newer value than the value we read before
  sending the lookup RPC.
  
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/nfsclient/nfs_vnops.c

Modified: stable/8/sys/nfsclient/nfs_vnops.c
==
--- stable/8/sys/nfsclient/nfs_vnops.c  Fri Oct 23 19:02:53 2009
(r198423)
+++ stable/8/sys/nfsclient/nfs_vnops.c  Fri Oct 23 19:52:29 2009
(r198424)
@@ -924,6 +924,7 @@ nfs_lookup(struct vop_lookup_args *ap)
struct vnode **vpp = ap-a_vpp;
struct mount *mp = dvp-v_mount;
struct vattr vattr;
+   time_t dmtime;
int flags = cnp-cn_flags;
struct vnode *newvp;
struct nfsmount *nmp;
@@ -935,7 +936,7 @@ nfs_lookup(struct vop_lookup_args *ap)
int error = 0, attrflag, fhsize, ltype;
int v3 = NFS_ISV3(dvp);
struct thread *td = cnp-cn_thread;
-   
+
*vpp = NULLVP;
if ((flags  ISLASTCN)  (mp-mnt_flag  MNT_RDONLY) 
(cnp-cn_nameiop == DELETE || cnp-cn_nameiop == RENAME))
@@ -992,6 +993,19 @@ nfs_lookup(struct vop_lookup_args *ap)
np-n_dmtime = 0;
mtx_unlock(np-n_mtx);
}
+
+   /*
+* Cache the modification time of the parent directory in case
+* the lookup fails and results in adding the first negative
+* name cache entry for the directory.  Since this is reading
+* a single time_t, don't bother with locking.  The
+* modification time may be a bit stale, but it must be read
+* before performing the lookup RPC to prevent a race where
+* another lookup updates the timestamp on the directory after
+* the lookup RPC has been performed on the server but before
+* n_dmtime is set at the end of this function.
+*/
+   dmtime = np-n_vattr.va_mtime.tv_sec;
error = 0;
newvp = NULLVP;
nfsstats.lookupcache_misses++;
@@ -1130,13 +1144,25 @@ nfsmout:
 * Maintain n_dmtime as the modification time
 * of the parent directory when the oldest -ve
 * name cache entry for this directory was
-* added.
+* added.  If a -ve cache entry has already
+* been added with a newer modification time
+* by a concurrent lookup, then don't bother
+* adding a cache entry.  The modification
+* time of the directory might have changed
+* due to the file this lookup failed to find
+* being created.  In that case a subsequent
+* lookup would incorrectly use the entry
+* added here instead of doing an extra
+* lookup.
 */

svn commit: r198425 - in stable/7/sys: . contrib/pf nfsclient

2009-10-23 Thread John Baldwin
Author: jhb
Date: Fri Oct 23 19:53:04 2009
New Revision: 198425
URL: http://svn.freebsd.org/changeset/base/198425

Log:
  MFC 198174:
  Close a race with caching of -ve name lookups in the NFS client.
  Specifically, clients only trust -ve cache entries while the directory
  remains unchanged and discard any -ve cache entries for a directory when
  they notice that the modification time of a directory entry changes.  The
  race involves two concurrent lookups as follows:
  - Thread A does a lookup for file 'foo' which sends a lookup RPC to the
server.  The lookup fails and the server replies.
  - The 'foo' file is created (either by the same client or a different
client) updating the modification time on the parent directory of 'foo'.
  - Thread B does a lookup for a different file 'bar' which updates the
cached attributes of the parent directory of 'foo' to reflect the new
modification time after 'foo' was created.
  - Thread A finally resumes execution to parse the reply from the NFS
server.  It adds a -ve cache entry and sets the cached value of the
directory's modification time that is used for invalidating -ve cached
lookups to the new modification time set by thread B.
  
  At this point, future lookups of 'foo' will honor the -ve cached entry
  until the cached entry is pushed out of the name cache's LRU or the
  modification time of the parent directory is changed again by some other
  change.  The fix is to read the directory's modification time before
  sending the lookup RPC and use that cached modification time when setting
  the directory's cached modification time.  Also, we do not add a -ve cache
  entry if another thread has added -ve cache entry that set the directory's
  cached modification time to a newer value than the value we read before
  sending the lookup RPC.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/nfsclient/nfs_vnops.c

Modified: stable/7/sys/nfsclient/nfs_vnops.c
==
--- stable/7/sys/nfsclient/nfs_vnops.c  Fri Oct 23 19:52:29 2009
(r198424)
+++ stable/7/sys/nfsclient/nfs_vnops.c  Fri Oct 23 19:53:04 2009
(r198425)
@@ -863,6 +863,7 @@ nfs_lookup(struct vop_lookup_args *ap)
struct vnode *dvp = ap-a_dvp;
struct vnode **vpp = ap-a_vpp;
struct vattr vattr;
+   time_t dmtime;
int flags = cnp-cn_flags;
struct vnode *newvp;
struct nfsmount *nmp;
@@ -874,7 +875,7 @@ nfs_lookup(struct vop_lookup_args *ap)
int error = 0, attrflag, fhsize;
int v3 = NFS_ISV3(dvp);
struct thread *td = cnp-cn_thread;
-   
+
*vpp = NULLVP;
if ((flags  ISLASTCN)  (dvp-v_mount-mnt_flag  MNT_RDONLY) 
(cnp-cn_nameiop == DELETE || cnp-cn_nameiop == RENAME))
@@ -929,6 +930,19 @@ nfs_lookup(struct vop_lookup_args *ap)
np-n_dmtime = 0;
mtx_unlock(np-n_mtx);
}
+
+   /*
+* Cache the modification time of the parent directory in case
+* the lookup fails and results in adding the first negative
+* name cache entry for the directory.  Since this is reading
+* a single time_t, don't bother with locking.  The
+* modification time may be a bit stale, but it must be read
+* before performing the lookup RPC to prevent a race where
+* another lookup updates the timestamp on the directory after
+* the lookup RPC has been performed on the server but before
+* n_dmtime is set at the end of this function.
+*/
+   dmtime = np-n_vattr.va_mtime.tv_sec;
error = 0;
newvp = NULLVP;
nfsstats.lookupcache_misses++;
@@ -1036,13 +1050,25 @@ nfsmout:
 * Maintain n_dmtime as the modification time
 * of the parent directory when the oldest -ve
 * name cache entry for this directory was
-* added.
+* added.  If a -ve cache entry has already
+* been added with a newer modification time
+* by a concurrent lookup, then don't bother
+* adding a cache entry.  The modification
+* time of the directory might have changed
+* due to the file this lookup failed to find
+* being created.  In that case a subsequent
+* lookup would incorrectly use the entry
+* added here instead of doing an extra
+* lookup.
 */
mtx_lock(np-n_mtx);
-   if (np-n_dmtime == 0)
-   np-n_dmtime = np-n_vattr.va_mtime.tv_sec;
-   mtx_unlock(np-n_mtx);
-   cache_enter(dvp, NULL, cnp);
+

svn commit: r198426 - head/sys/dev/siis

2009-10-23 Thread Alexander Motin
Author: mav
Date: Fri Oct 23 21:33:26 2009
New Revision: 198426
URL: http://svn.freebsd.org/changeset/base/198426

Log:
  Reimplement device reset sequence in more controller-specific way.

Modified:
  head/sys/dev/siis/siis.c

Modified: head/sys/dev/siis/siis.c
==
--- head/sys/dev/siis/siis.cFri Oct 23 19:53:04 2009(r198425)
+++ head/sys/dev/siis/siis.cFri Oct 23 21:33:26 2009(r198426)
@@ -80,7 +80,6 @@ static void siis_portinit(device_t dev);
 static int siis_wait_ready(device_t dev, int t);
 
 static int siis_sata_connect(struct siis_channel *ch);
-static int siis_sata_phy_reset(device_t dev);
 
 static void siis_issue_read_log(device_t dev);
 static void siis_process_read_log(device_t dev, union ccb *ccb);
@@ -1250,16 +1249,27 @@ siis_portinit(device_t dev)
siis_wait_ready(dev, 1000);
 }
 
-#if 0
-static void
+static int
 siis_devreset(device_t dev)
 {
struct siis_channel *ch = device_get_softc(dev);
+   int timeout = 0;
+   uint32_t val;
 
ATA_OUTL(ch-r_mem, SIIS_P_CTLSET, SIIS_P_CTL_DEV_RESET);
-   siis_wait_ready(dev, 1000);
+   while (((val = ATA_INL(ch-r_mem, SIIS_P_STS)) 
+   SIIS_P_CTL_DEV_RESET) != 0) {
+   DELAY(1000);
+   if (timeout++  100) {
+   device_printf(dev, device reset stuck (timeout %dms) 
+   status = %08x\n, timeout, val);
+   return (EBUSY);
+   }
+   }
+   if (bootverbose)
+   device_printf(dev, device reset time=%dms\n, timeout);
+   return (0);
 }
-#endif
 
 static int
 siis_wait_ready(device_t dev, int t)
@@ -1287,6 +1297,7 @@ siis_reset(device_t dev)
 {
struct siis_channel *ch = device_get_softc(dev);
int i;
+   uint32_t val;
 
if (bootverbose)
device_printf(dev, SIIS reset...\n);
@@ -1303,10 +1314,7 @@ siis_reset(device_t dev)
}
xpt_done(fccb);
}
-   /* Disable port interrupts */
-   ATA_OUTL(ch-r_mem, SIIS_P_IECLR, 0x);
-   /* Kill the engine and requeue all running commands. */
-   siis_portinit(dev);
+   /* Requeue all running commands. */
for (i = 0; i  SIIS_MAX_SLOTS; i++) {
/* Do we have a running request on slot? */
if (ch-slot[i].state  SIIS_SLOT_RUNNING)
@@ -1314,8 +1322,23 @@ siis_reset(device_t dev)
/* XXX; Commands in loading state. */
siis_end_transaction(ch-slot[i], SIIS_ERR_INNOCENT);
}
+   /* Disable port interrupts */
+   ATA_OUTL(ch-r_mem, SIIS_P_IECLR, 0x);
+   /* Set speed limit. */
+   if (ch-sata_rev == 1)
+   val = ATA_SC_SPD_SPEED_GEN1;
+   else if (ch-sata_rev == 2)
+   val = ATA_SC_SPD_SPEED_GEN2;
+   else if (ch-sata_rev == 3)
+   val = ATA_SC_SPD_SPEED_GEN3;
+   else
+   val = 0;
+   ATA_OUTL(ch-r_mem, SIIS_P_SCTL,
+   ATA_SC_DET_IDLE | val | ((ch-pm_level  0) ? 0 :
+   (ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER)));
+   siis_devreset(dev);
/* Reset and reconnect PHY, */
-   if (!siis_sata_phy_reset(dev)) {
+   if (!siis_sata_connect(ch)) {
ch-devices = 0;
/* Enable port interrupts */
ATA_OUTL(ch-r_mem, SIIS_P_IESET, SIIS_P_IX_ENABLED);
@@ -1327,9 +1350,8 @@ siis_reset(device_t dev)
return;
}
/* Wait for clearing busy status. */
-   if (siis_wait_ready(dev, 1)) {
+   if (siis_wait_ready(dev, 1))
device_printf(dev, device ready timeout\n);
-   }
ch-devices = 1;
/* Enable port interrupts */
ATA_OUTL(ch-r_mem, SIIS_P_IS, 0x);
@@ -1420,32 +1442,6 @@ siis_sata_connect(struct siis_channel *c
return (1);
 }
 
-static int
-siis_sata_phy_reset(device_t dev)
-{
-   struct siis_channel *ch = device_get_softc(dev);
-   uint32_t val;
-
-   if (bootverbose)
-   device_printf(dev, hardware reset ...\n);
-   ATA_OUTL(ch-r_mem, SIIS_P_SCTL, ATA_SC_IPM_DIS_PARTIAL |
-   ATA_SC_IPM_DIS_SLUMBER | ATA_SC_DET_RESET);
-   DELAY(5);
-   if (ch-sata_rev == 1)
-   val = ATA_SC_SPD_SPEED_GEN1;
-   else if (ch-sata_rev == 2)
-   val = ATA_SC_SPD_SPEED_GEN2;
-   else if (ch-sata_rev == 3)
-   val = ATA_SC_SPD_SPEED_GEN3;
-   else
-   val = 0;
-   ATA_OUTL(ch-r_mem, SIIS_P_SCTL,
-   ATA_SC_DET_IDLE | val | ((ch-pm_level  0) ? 0 :
-   (ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER)));
-   DELAY(5);
-   return (siis_sata_connect(ch));
-}
-
 static void
 siisaction(struct cam_sim *sim, union ccb *ccb)
 {
___
svn-src-all@freebsd.org mailing list

svn commit: r198427 - head/sys/powerpc/aim

2009-10-23 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct 23 21:36:33 2009
New Revision: 198427
URL: http://svn.freebsd.org/changeset/base/198427

Log:
  Add some more paranoia to setting HID registers, and update the AIM
  clock routines to work better with SMP. This makes SMP work fully and
  stably on an Xserve G5.
  
  Obtained from:Book-E (clock bits)

Modified:
  head/sys/powerpc/aim/clock.c
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/aim/mp_cpudep.c

Modified: head/sys/powerpc/aim/clock.c
==
--- head/sys/powerpc/aim/clock.cFri Oct 23 21:33:26 2009
(r198426)
+++ head/sys/powerpc/aim/clock.cFri Oct 23 21:36:33 2009
(r198427)
@@ -95,8 +95,7 @@ static struct timecounter decr_timecount
 void
 decr_intr(struct trapframe *frame)
 {
-   longtick;
-   int nticks;
+   int32_t tick, nticks;
 
/*
 * Check whether we are initialized.
@@ -112,13 +111,17 @@ decr_intr(struct trapframe *frame)
for (nticks = 0; tick  0; nticks++)
tick += ticks_per_intr;
mtdec(tick);
+if (nticks  5) printf(BIG NTICKS on CPU %d: %x\n,PCPU_GET(cpuid),nticks);
 
-   if (PCPU_GET(cpuid) == 0) {
-   while (nticks--  0)
+   while (nticks--  0) {
+   if (PCPU_GET(cpuid) == 0)
hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
-   } else {
-   while (nticks--  0)
+   else
hardclock_cpu(TRAPF_USERMODE(frame));
+
+   statclock(TRAPF_USERMODE(frame));
+   if (profprocs != 0)
+   profclock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
}
 }
 
@@ -145,6 +148,8 @@ decr_init(void)
ticks_per_intr = ticks_per_sec / hz;
mtdec(ticks_per_intr);
 
+   set_cputicker(mftb, ticks_per_sec, 0);
+
mtmsr(msr);
 }
 

Modified: head/sys/powerpc/aim/machdep.c
==
--- head/sys/powerpc/aim/machdep.c  Fri Oct 23 21:33:26 2009
(r198426)
+++ head/sys/powerpc/aim/machdep.c  Fri Oct 23 21:36:33 2009
(r198427)
@@ -885,6 +885,8 @@ cpu_initclocks(void)
 {
 
decr_tc_init();
+   stathz = hz;
+   profhz = hz;
 }
 
 /*

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cFri Oct 23 21:33:26 2009
(r198426)
+++ head/sys/powerpc/aim/mp_cpudep.cFri Oct 23 21:36:33 2009
(r198427)
@@ -50,7 +50,7 @@ __FBSDID($FreeBSD$);
 
 void *ap_pcpu;
 
-static register_t bsp_state[8];
+static register_t bsp_state[8] __aligned(8);
 
 static void cpudep_save_config(void *dummy);
 SYSINIT(cpu_save_config, SI_SUB_CPU, SI_ORDER_ANY, cpudep_save_config, NULL);
@@ -184,6 +184,8 @@ cpudep_save_config(void *dummy)
__asm __volatile (mfspr %0,%2; mr %1,%0; srdi %0,%0,32
: =r (bsp_state[6]),=r (bsp_state[7]) : K (SPR_HID5));
 
+   powerpc_sync();
+
break;
case MPC7450:
case MPC7455:
@@ -224,17 +226,23 @@ cpudep_ap_setup()
 * See Table 2-3, 970MP manual
 */
 
+   __asm __volatile(mtasr %0; sync :: r(0));
__asm __volatile( \
ld  %0,0(%2);   \
+   sync; isync;\
mtspr   %1, %0; \
mfspr   %0, %1; mfspr   %0, %1; mfspr   %0, %1; \
-   mfspr   %0, %1; mfspr   %0, %1; mfspr   %0, %1;
+   mfspr   %0, %1; mfspr   %0, %1; mfspr   %0, %1; \
+   sync; isync 
: =r(reg) : K(SPR_HID0), r(bsp_state));
-   __asm __volatile(ld %0, 8(%2); mtspr %1, %0; mtspr %1, %0; \
-   isync : =r(reg) : K(SPR_HID1), r(bsp_state));
-   __asm __volatile(ld %0, 16(%2); sync; mtspr %1, %0; isync;
+   __asm __volatile(ld %0, 8(%2); sync; isync;\
+   mtspr %1, %0; mtspr %1, %0; sync; isync
+   : =r(reg) : K(SPR_HID1), r(bsp_state));
+   __asm __volatile(ld %0, 16(%2); sync; isync;   \
+   mtspr %1, %0; sync; isync;
: =r(reg) : K(SPR_HID4), r(bsp_state));
-   __asm __volatile(ld %0, 24(%2); sync; mtspr %1, %0; isync;
+   __asm __volatile(ld %0, 24(%2); sync; isync;   \
+   mtspr %1, %0; sync; isync;
: =r(reg) : K(SPR_HID5), r(bsp_state));
 
powerpc_sync();
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to 

svn commit: r198428 - head/sys/powerpc/aim

2009-10-23 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct 23 21:44:46 2009
New Revision: 198428
URL: http://svn.freebsd.org/changeset/base/198428

Log:
  Remove debugging printf that snuck in here.
  
  Pointy hat to:me

Modified:
  head/sys/powerpc/aim/clock.c

Modified: head/sys/powerpc/aim/clock.c
==
--- head/sys/powerpc/aim/clock.cFri Oct 23 21:36:33 2009
(r198427)
+++ head/sys/powerpc/aim/clock.cFri Oct 23 21:44:46 2009
(r198428)
@@ -111,7 +111,6 @@ decr_intr(struct trapframe *frame)
for (nticks = 0; tick  0; nticks++)
tick += ticks_per_intr;
mtdec(tick);
-if (nticks  5) printf(BIG NTICKS on CPU %d: %x\n,PCPU_GET(cpuid),nticks);
 
while (nticks--  0) {
if (PCPU_GET(cpuid) == 0)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198432 - head/sys/dev/hwpmc

2009-10-23 Thread Joseph Koshy
Author: jkoshy
Date: Sat Oct 24 01:58:10 2009
New Revision: 198432
URL: http://svn.freebsd.org/changeset/base/198432

Log:
  Only claim that the PMC_CLASS_IAF PMCs are supported by a CPU if
  there are PMCs on the CPU that belong to the class.
  
  Review and testing by:fabient

Modified:
  head/sys/dev/hwpmc/hwpmc_core.c

Modified: head/sys/dev/hwpmc/hwpmc_core.c
==
--- head/sys/dev/hwpmc/hwpmc_core.c Fri Oct 23 22:53:01 2009
(r198431)
+++ head/sys/dev/hwpmc/hwpmc_core.c Sat Oct 24 01:58:10 2009
(r198432)
@@ -1977,11 +1977,21 @@ pmc_core_initialize(struct pmc_mdep *md,
core_iaf_npmc = cpuid[CORE_CPUID_EDX]  0x1F;
core_iaf_width = (cpuid[CORE_CPUID_EDX]  5)  0xFF;
 
-   iaf_initialize(md, maxcpu, core_iaf_npmc, core_iaf_width);
-
-   core_pmcmask |= ((1ULL  core_iaf_npmc) - 1) 
-   IAF_OFFSET;
-
+   if (core_iaf_npmc  0) {
+   iaf_initialize(md, maxcpu, core_iaf_npmc,
+   core_iaf_width);
+   core_pmcmask |= ((1ULL  core_iaf_npmc) - 1) 
+   IAF_OFFSET;
+   } else {
+   /*
+* Adjust the number of classes exported to
+* user space.
+*/
+   md-pmd_nclass--;
+   KASSERT(md-pmd_nclass == 2,
+   ([core,%d] unexpected nclass %d, __LINE__,
+   md-pmd_nclass));
+   }
}
 
PMCDBG(MDP,INI,1,core-init pmcmask=0x%jx iafri=%d, core_pmcmask,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r198433 - head/lib/libpmc

2009-10-23 Thread Joseph Koshy
Author: jkoshy
Date: Sat Oct 24 04:11:40 2009
New Revision: 198433
URL: http://svn.freebsd.org/changeset/base/198433

Log:
  Not all Intel Core (TM) CPUs implement PMC_CLASS_IAF fixed-function
  counters.  For such CPUs, use an alternate mapping of convenience
  names to events supported by PMC_CLASS_IAP programmable counters.
  
  Testing and review by:fabient

Modified:
  head/lib/libpmc/libpmc.c

Modified: head/lib/libpmc/libpmc.c
==
--- head/lib/libpmc/libpmc.cSat Oct 24 01:58:10 2009(r198432)
+++ head/lib/libpmc/libpmc.cSat Oct 24 04:11:40 2009(r198433)
@@ -442,6 +442,10 @@ static struct pmc_event_alias core_alias
 /*
  * Intel Core2 (Family 6, Model F), Core2Extreme (Family 6, Model 17H)
  * and Atom (Family 6, model 1CH) PMCs.
+ *
+ * We map aliases to events on the fixed-function counters if these
+ * are present.  Note that not all CPUs in this family contain fixed-function
+ * counters.
  */
 
 static struct pmc_event_alias core2_aliases[] = {
@@ -454,8 +458,22 @@ static struct pmc_event_alias core2_alia
EV_ALIAS(unhalted-cycles, iaf-cpu-clk-unhalted.core),
EV_ALIAS(NULL, NULL)
 };
-#defineatom_aliasescore2_aliases
-#define corei7_aliases core2_aliases
+
+static struct pmc_event_alias core2_aliases_without_iaf[] = {
+   EV_ALIAS(branches,iap-br-inst-retired.any),
+   EV_ALIAS(branch-mispredicts,  iap-br-inst-retired.mispred),
+   EV_ALIAS(cycles,  tsc-tsc),
+   EV_ALIAS(ic-misses,   iap-l1i-misses),
+   EV_ALIAS(instructions,iap-inst-retired.any_p),
+   EV_ALIAS(interrupts,  iap-hw-int-rcv),
+   EV_ALIAS(unhalted-cycles, iap-cpu-clk-unhalted.core_p),
+   EV_ALIAS(NULL, NULL)
+};
+
+#defineatom_aliasescore2_aliases
+#defineatom_aliases_without_iafcore2_aliases_without_iaf
+#define corei7_aliases core2_aliases
+#define corei7_aliases_without_iaf core2_aliases_without_iaf
 
 #defineIAF_KW_OS   os
 #defineIAF_KW_USR  usr
@@ -2379,6 +2397,10 @@ pmc_init(void)
uint32_t abi_version;
struct module_stat pmc_modstat;
struct pmc_op_getcpuinfo op_cpu_info;
+#if defined(__amd64__) || defined(__i386__)
+   int cpu_has_iaf_counters;
+   unsigned int t;
+#endif
 
if (pmc_syscall != -1) /* already inited */
return (0);
@@ -2420,6 +2442,8 @@ pmc_init(void)
if (pmc_class_table == NULL)
return (-1);
 
+   for (n = 0; n  PMC_CLASS_TABLE_SIZE; n++)
+   pmc_class_table[n] = NULL;
 
/*
 * Fill in the class table.
@@ -2427,6 +2451,14 @@ pmc_init(void)
n = 0;
 #if defined(__amd64__) || defined(__i386__)
pmc_class_table[n++] = tsc_class_table_descr;
+
+   /*
+* Check if this CPU has fixed function counters.
+*/
+   cpu_has_iaf_counters = 0;
+   for (t = 0; t  cpu_info.pm_nclass; t++)
+   if (cpu_info.pm_classes[t].pm_class == PMC_CLASS_IAF)
+   cpu_has_iaf_counters = 1;
 #endif
 
 #definePMC_MDEP_INIT(C) do {   \
@@ -2436,6 +2468,16 @@ pmc_init(void)
PMC_TABLE_SIZE(C##_pmc_classes);\
} while (0)
 
+#definePMC_MDEP_INIT_INTEL_V2(C) do {  
\
+   PMC_MDEP_INIT(C);   \
+   if (cpu_has_iaf_counters)   \
+   pmc_class_table[n++] = iaf_class_table_descr;  \
+   else\
+   pmc_mdep_event_aliases =\
+   C##_aliases_without_iaf;\
+   pmc_class_table[n] = C##_class_table_descr;\
+   } while (0)
+
/* Configure the event name parser. */
switch (cpu_info.pm_cputype) {
 #if defined(__i386__)
@@ -2461,24 +2503,17 @@ pmc_init(void)
pmc_class_table[n] = k8_class_table_descr;
break;
case PMC_CPU_INTEL_ATOM:
-   PMC_MDEP_INIT(atom);
-   pmc_class_table[n++] = iaf_class_table_descr;
-   pmc_class_table[n]   = atom_class_table_descr;
+   PMC_MDEP_INIT_INTEL_V2(atom);
break;
case PMC_CPU_INTEL_CORE:
PMC_MDEP_INIT(core);
-   pmc_class_table[n] = core_class_table_descr;
break;
case PMC_CPU_INTEL_CORE2:
case PMC_CPU_INTEL_CORE2EXTREME:
-   PMC_MDEP_INIT(core2);
-   pmc_class_table[n++] = iaf_class_table_descr;
-   pmc_class_table[n]   = core2_class_table_descr;
+   PMC_MDEP_INIT_INTEL_V2(core2);

svn commit: r198434 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern sys

2009-10-23 Thread Ruslan Ermilov
Author: ru
Date: Sat Oct 24 04:55:14 2009
New Revision: 198434
URL: http://svn.freebsd.org/changeset/base/198434

Log:
  MFC r198295:
  
  Random number generator initialization cleanup:
  
  - Introduce new SI_SUB_RANDOM point in boot sequence to make it
  clear from where one may start using random(9).  It should be as
  early as possible, so place it just after SI_SUB_CPU where we
  have some randomness on most platforms via get_cyclecount().
  
  - Move stack protector initialization to be after SI_SUB_RANDOM
  as before this point we have no randomness at all.  This fixes
  stack protector to actually protect stack with some random guard
  value instead of a well-known one.
  
  Note that this patch doesn't try to address arc4random(9) issues.
  With current code, it will be implicitly seeded by stack protector
  and hence will get the same entropy as random(9).  It will be
  securely reseeded once /dev/random is feeded by some entropy from
  userland.
  
  Submitted by: Maxim Dounin mdou...@mdounin.ru
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/kern/init_main.c
  stable/8/sys/kern/stack_protector.c
  stable/8/sys/sys/kernel.h

Modified: stable/8/sys/kern/init_main.c
==
--- stable/8/sys/kern/init_main.c   Sat Oct 24 04:11:40 2009
(r198433)
+++ stable/8/sys/kern/init_main.c   Sat Oct 24 04:55:14 2009
(r198434)
@@ -557,6 +557,19 @@ proc0_post(void *dummy __unused)
 }
 SYSINIT(p0post, SI_SUB_INTRINSIC_POST, SI_ORDER_FIRST, proc0_post, NULL);
 
+static void
+random_init(void *dummy __unused)
+{
+
+   /*
+* After CPU has been started we have some randomness on most
+* platforms via get_cyclecount().  For platforms that don't
+* we will reseed random(9) in proc0_post() as well.
+*/
+   srandom(get_cyclecount());
+}
+SYSINIT(random, SI_SUB_RANDOM, SI_ORDER_FIRST, random_init, NULL);
+
 /*
  ***
  

Modified: stable/8/sys/kern/stack_protector.c
==
--- stable/8/sys/kern/stack_protector.c Sat Oct 24 04:11:40 2009
(r198433)
+++ stable/8/sys/kern/stack_protector.c Sat Oct 24 04:55:14 2009
(r198434)
@@ -28,5 +28,4 @@ __stack_chk_init(void *dummy __unused)
for (i = 0; i  __arraycount(guard); i++)
__stack_chk_guard[i] = guard[i];
 }
-/* SI_SUB_EVENTHANDLER is right after SI_SUB_LOCK used by arc4rand() init. */
-SYSINIT(stack_chk, SI_SUB_EVENTHANDLER, SI_ORDER_ANY, __stack_chk_init, NULL);
+SYSINIT(stack_chk, SI_SUB_RANDOM, SI_ORDER_ANY, __stack_chk_init, NULL);

Modified: stable/8/sys/sys/kernel.h
==
--- stable/8/sys/sys/kernel.h   Sat Oct 24 04:11:40 2009(r198433)
+++ stable/8/sys/sys/kernel.h   Sat Oct 24 04:55:14 2009(r198434)
@@ -109,6 +109,7 @@ enum sysinit_sub_id {
SI_SUB_VNET_PRELINK = 0x1E0,/* vnet init before modules */
SI_SUB_KLD  = 0x200,/* KLD and module setup */
SI_SUB_CPU  = 0x210,/* CPU resource(s)*/
+   SI_SUB_RANDOM   = 0x212,/* random number generator */
SI_SUB_KDTRACE  = 0x214,/* Kernel dtrace hooks */
SI_SUB_MAC  = 0x218,/* TrustedBSD MAC subsystem */
SI_SUB_MAC_POLICY   = 0x21C,/* TrustedBSD MAC policies */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org