svn commit: r314195 - head/sys/vm

2017-02-24 Thread Konstantin Belousov
Author: kib
Date: Fri Feb 24 08:09:16 2017
New Revision: 314195
URL: https://svnweb.freebsd.org/changeset/base/314195

Log:
  Properly handle possible underflow in vm_fault_prefault().
  
  In vm_fault_prefault(), if backward count causes underflow in
  calculation of
starta = addra - backward * PAGE_SIZE;
  then starta must be clipped to entry->start, instead of zero.
  Clipping to zero allowed mapping outside of the map entries address
  ranges, in particular, map at zero.
  
  Submitted by: Yanko Yankulov 
  Reviewed by:  alc
  MFC after:1 week

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==
--- head/sys/vm/vm_fault.c  Fri Feb 24 07:53:56 2017(r314194)
+++ head/sys/vm/vm_fault.c  Fri Feb 24 08:09:16 2017(r314195)
@@ -1368,11 +1368,12 @@ vm_fault_prefault(const struct faultstat
 
entry = fs->entry;
 
-   starta = addra - backward * PAGE_SIZE;
-   if (starta < entry->start) {
+   if (addra < backward * PAGE_SIZE) {
starta = entry->start;
-   } else if (starta > addra) {
-   starta = 0;
+   } else {
+   starta = addra - backward * PAGE_SIZE;
+   if (starta < entry->start)
+   starta = entry->start;
}
 
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314179 - in head: contrib/netbsd-tests/lib/librt include lib/libc/gen lib/libc/include share/man/man3 sys/kern

2017-02-24 Thread Konstantin Belousov
On Thu, Feb 23, 2017 at 07:36:39PM +, Eric van Gyzen wrote:
> Modified: head/include/semaphore.h
> ==
> --- head/include/semaphore.h  Thu Feb 23 19:32:25 2017(r314178)
> +++ head/include/semaphore.h  Thu Feb 23 19:36:38 2017(r314179)
> @@ -59,6 +59,8 @@ int  sem_init(sem_t *, int, unsigned int
>  sem_t*sem_open(const char *, int, ...);
>  int   sem_post(sem_t *);
>  int   sem_timedwait(sem_t * __restrict, const struct timespec * __restrict);
> +int   sem_clockwait_np(sem_t * __restrict, __clockid_t, int,
> + const struct timespec *, struct timespec *);
I argue that semaphore.h is POSIX include file and the declaration of
sem_clockwait_np(), despite being in implementation (non-portable)
namespace, still should be braced with #if __BSD_VISIBLE.

>  int   sem_trywait(sem_t *);
>  int   sem_unlink(const char *);
>  int   sem_wait(sem_t *);
> 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314196 - head/sys/cam/ctl

2017-02-24 Thread Alexander Motin
Author: mav
Date: Fri Feb 24 09:16:21 2017
New Revision: 314196
URL: https://svnweb.freebsd.org/changeset/base/314196

Log:
  Unify ATIO/INOT CCBs requeuing.
  
  MFC after:2 weeks

Modified:
  head/sys/cam/ctl/scsi_ctl.c

Modified: head/sys/cam/ctl/scsi_ctl.c
==
--- head/sys/cam/ctl/scsi_ctl.c Fri Feb 24 08:09:16 2017(r314195)
+++ head/sys/cam/ctl/scsi_ctl.c Fri Feb 24 09:16:21 2017(r314196)
@@ -210,6 +210,10 @@ static voidctlfe_dump_queue(struct ctl
 static voidctlfe_datamove(union ctl_io *io);
 static voidctlfe_done(union ctl_io *io);
 static voidctlfe_dump(void);
+static voidctlfe_free_ccb(struct cam_periph *periph,
+   union ccb *ccb);
+static voidctlfe_requeue_ccb(struct cam_periph *periph,
+   union ccb *ccb, int unlock);
 
 static struct periph_driver ctlfe_driver =
 {
@@ -802,6 +806,7 @@ ctlfestart(struct cam_periph *periph, un
softc = (struct ctlfe_lun_softc *)periph->softc;
softc->ccbs_alloced++;
 
+next:
ccb_h = TAILQ_FIRST(&softc->work_queue);
if (ccb_h == NULL) {
softc->ccbs_freed++;
@@ -845,26 +850,12 @@ ctlfestart(struct cam_periph *periph, un
start_ccb->ccb_h.func_code = XPT_ABORT;
start_ccb->cab.abort_ccb = (union ccb *)atio;
xpt_action(start_ccb);
-   softc->ccbs_freed++;
-   xpt_release_ccb(start_ccb);
 
-   /*
-* Send the ATIO back down to the SIM.
-* For a wildcard attachment, commands can come in
-* with a specific target/lun.  Reset the target and
-* LUN fields back to the wildcard values before we
-* send them back down to the SIM.
-*/
-   if (softc->flags & CTLFE_LUN_WILDCARD) {
-   atio->ccb_h.target_id = CAM_TARGET_WILDCARD;
-   atio->ccb_h.target_lun = CAM_LUN_WILDCARD;
-   }
-   xpt_action((union ccb *)atio);
+   ctlfe_requeue_ccb(periph, (union ccb *)atio,
+   /* unlock */0);
 
-   /* If we still have work to do, ask for another CCB. */
-   if (!TAILQ_EMPTY(&softc->work_queue))
-   xpt_schedule(periph, /*priority*/ 1);
-   return;
+   /* XPT_ABORT is not queued, so we can take next I/O. */
+   goto next;
}
data_ptr = NULL;
dxfer_len = 0;
@@ -997,6 +988,37 @@ ctlfe_free_ccb(struct cam_periph *periph
}
 }
 
+/*
+ * Send the ATIO/INOT back to the SIM, or free it if periph was invalidated.
+ */
+static void
+ctlfe_requeue_ccb(struct cam_periph *periph, union ccb *ccb, int unlock)
+{
+   struct ctlfe_lun_softc *softc;
+
+   if (periph->flags & CAM_PERIPH_INVALID) {
+   ctlfe_free_ccb(periph, ccb);
+   if (unlock)
+   cam_periph_unlock(periph);
+   return;
+   }
+   if (unlock)
+   cam_periph_unlock(periph);
+
+   /*
+* For a wildcard attachment, commands can come in with a specific
+* target/lun.  Reset the target and LUN fields back to the wildcard
+* values before we send them back down to the SIM.
+*/
+   softc = (struct ctlfe_lun_softc *)periph->softc;
+   if (softc->flags & CTLFE_LUN_WILDCARD) {
+   ccb->ccb_h.target_id = CAM_TARGET_WILDCARD;
+   ccb->ccb_h.target_lun = CAM_LUN_WILDCARD;
+   }
+
+   xpt_action(ccb);
+}
+
 static int
 ctlfe_adjust_cdb(struct ccb_accept_tio *atio, uint32_t offset)
 {
@@ -1260,25 +1282,9 @@ ctlfedone(struct cam_periph *periph, uni
if ((io->io_hdr.flags & CTL_FLAG_DMA_INPROG) == 0) {
softc->ccbs_freed++;
xpt_release_ccb(done_ccb);
-   /*
-* For a wildcard attachment, commands can come in
-* with a specific target/lun.  Reset the target
-* and LUN fields back to the wildcard values before
-* we send them back down to the SIM.  The SIM has
-* a wildcard LUN enabled, not whatever target/lun
-* these happened to be.
-*/
-   if (softc->flags & CTLFE_LUN_WILDCARD) {
-   atio->ccb_h.target_id = CAM_TARGET_WILDCARD;
-   atio->ccb_h.target_lun = CAM_LUN_WILDCARD;
-   }
-

svn commit: r314200 - head/sys/cam/ctl

2017-02-24 Thread Alexander Motin
Author: mav
Date: Fri Feb 24 11:25:32 2017
New Revision: 314200
URL: https://svnweb.freebsd.org/changeset/base/314200

Log:
  We can't access periph after ctlfe_free_ccb().
  
  MFC after:2 weeks

Modified:
  head/sys/cam/ctl/scsi_ctl.c

Modified: head/sys/cam/ctl/scsi_ctl.c
==
--- head/sys/cam/ctl/scsi_ctl.c Fri Feb 24 11:07:49 2017(r314199)
+++ head/sys/cam/ctl/scsi_ctl.c Fri Feb 24 11:25:32 2017(r314200)
@@ -995,11 +995,13 @@ static void
 ctlfe_requeue_ccb(struct cam_periph *periph, union ccb *ccb, int unlock)
 {
struct ctlfe_lun_softc *softc;
+   struct mtx *mtx;
 
if (periph->flags & CAM_PERIPH_INVALID) {
+   mtx = cam_periph_mtx(periph);
ctlfe_free_ccb(periph, ccb);
if (unlock)
-   cam_periph_unlock(periph);
+   mtx_unlock(mtx);
return;
}
if (unlock)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314203 - head/sys/dev/isp

2017-02-24 Thread Alexander Motin
Author: mav
Date: Fri Feb 24 12:11:17 2017
New Revision: 314203
URL: https://svnweb.freebsd.org/changeset/base/314203

Log:
  Fix missing xpt_done() for ATIO/INOT on missing LUN.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/isp/isp_freebsd.c

Modified: head/sys/dev/isp/isp_freebsd.c
==
--- head/sys/dev/isp/isp_freebsd.c  Fri Feb 24 11:34:00 2017
(r314202)
+++ head/sys/dev/isp/isp_freebsd.c  Fri Feb 24 12:11:17 2017
(r314203)
@@ -3428,9 +3428,10 @@ isp_action(struct cam_sim *sim, union cc
else
str = "XPT_ACCEPT_TARGET_IO";
ISP_PATH_PRT(isp, ISP_LOGWARN, ccb->ccb_h.path,
-   "%s: [0x%x] no state pointer found for %s\n",
+   "%s: no state pointer found for %s\n",
__func__, str);
ccb->ccb_h.status = CAM_DEV_NOT_THERE;
+   xpt_done(ccb);
break;
}
ccb->ccb_h.spriv_field0 = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314204 - head/sys/cam/ctl

2017-02-24 Thread Alexander Motin
Author: mav
Date: Fri Feb 24 12:12:30 2017
New Revision: 314204
URL: https://svnweb.freebsd.org/changeset/base/314204

Log:
  Explicitly abort ATIO if CTIO sending status has failed.
  
  This helps SIM to free related resources in questionable cases.
  
  MFC after:2 weeks

Modified:
  head/sys/cam/ctl/scsi_ctl.c

Modified: head/sys/cam/ctl/scsi_ctl.c
==
--- head/sys/cam/ctl/scsi_ctl.c Fri Feb 24 12:11:17 2017(r314203)
+++ head/sys/cam/ctl/scsi_ctl.c Fri Feb 24 12:12:30 2017(r314204)
@@ -1282,6 +1282,14 @@ ctlfedone(struct cam_periph *periph, uni
 * datamove done routine.
 */
if ((io->io_hdr.flags & CTL_FLAG_DMA_INPROG) == 0) {
+   /* Abort ATIO if CTIO sending status has failed. */
+   if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) !=
+   CAM_REQ_CMP) {
+   done_ccb->ccb_h.func_code = XPT_ABORT;
+   done_ccb->cab.abort_ccb = (union ccb *)atio;
+   xpt_action(done_ccb);
+   }
+
softc->ccbs_freed++;
xpt_release_ccb(done_ccb);
ctlfe_requeue_ccb(periph, (union ccb *)atio,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314087 - head/sys/x86/x86

2017-02-24 Thread Konstantin Belousov
On Thu, Feb 23, 2017 at 06:33:43AM +1100, Bruce Evans wrote:
> On Wed, 22 Feb 2017, Konstantin Belousov wrote:
> 
> > Log:
> >  More fixes for regression in r313898 on i386.
> >  Use long long constants where needed.
> 
> The long long abomination is never needed, and is always a style bug.
I never saw any explanation behind this claim.  Esp. the first part
of it, WRT 'never needed'.

> I don't like using explicit long constants either.  Here the number of bits
> in the register is fixed by the hardware at 64.  The number of bits in a
> long on amd64 and a long on i386 is only fixed by ABI because the ABI is
> broken for historical reasons.
I really cannot make any sense of this statement.

>  Only very MD code can safely assume the
> size of long and long long.  This code was MD enough before it was merged,
> but now it shouldn't use long since that varies between amd64 and i386,
> and it shouldn't use long long since that is a style bug.

Well, I do not see anything wrong with long long, at least until
explained.

Anyway, below is the patch to use uint64_t cast in important place,
and removal of LL suffix in unimportant expression.

diff --git a/sys/x86/x86/x86_mem.c b/sys/x86/x86/x86_mem.c
index d639224f840..8bc4d3917a0 100644
--- a/sys/x86/x86/x86_mem.c
+++ b/sys/x86/x86/x86_mem.c
@@ -260,7 +260,7 @@ x86_mrfetch(struct mem_range_softc *sc)
 
/* Compute the range from the mask. Ick. */
mrd->mr_len = (~(msrv & mtrr_physmask) &
-   (mtrr_physmask | 0xfffLL)) + 1;
+   (mtrr_physmask | 0xfff)) + 1;
if (!mrvalid(mrd->mr_base, mrd->mr_len))
mrd->mr_flags |= MDF_BOGUS;
 
@@ -638,7 +638,8 @@ x86_mrinit(struct mem_range_softc *sc)
 * Determine the size of the PhysMask and PhysBase fields in
 * the variable range MTRRs.
 */
-   mtrr_physmask = (((uint64_t)1 << cpu_maxphyaddr) - 1) & ~0xfffULL;
+   mtrr_physmask = (((uint64_t)1 << cpu_maxphyaddr) - 1) &
+   ~(uint64_t)0xfff;
 
/* If fixed MTRRs supported and enabled. */
if ((mtrrcap & MTRR_CAP_FIXED) && (mtrrdef & MTRR_DEF_FIXED_ENABLE)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314192 - in head/sys: conf dev/iwm modules/iwm

2017-02-24 Thread Cy Schubert
In message <201702240707.v1o77was011...@repo.freebsd.org>, Adrian Chadd 
writes:
> Author: adrian
> Date: Fri Feb 24 07:07:58 2017
> New Revision: 314192
> URL: https://svnweb.freebsd.org/changeset/base/314192
> 
> Log:
>   [iwm] Add support for Firmware paging, needed for newer 8000C firmware.
>   
>   * Uses the IWM_FW_PAGING_BLOCK_CMD firmware command to tell the firmware
> what memory ranges to use for paging.
>   
>   Obtained from:  dragonflybsd.git 8a5b199964f8e7bdb00039f0b48817a01b402f
> 18
> 
> Modified:
>   head/sys/conf/files
>   head/sys/dev/iwm/if_iwm.c
>   head/sys/dev/iwm/if_iwm_debug.h
>   head/sys/dev/iwm/if_iwmreg.h
>   head/sys/dev/iwm/if_iwmvar.h
>   head/sys/modules/iwm/Makefile

Looks like you forgot svn add.

--- all_subdir_iwm ---
make[4]: make[4]: don't know how to make if_iwm_fw.c. Stop

make[4]: stopped in /opt/src/svn-current/sys/modules/iwm
*** [all_subdir_iwm] Error code 2

make[3]: stopped in /opt/src/svn-current/sys/modules


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


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


Re: svn commit: r314179 - in head: contrib/netbsd-tests/lib/librt include lib/libc/gen lib/libc/include share/man/man3 sys/kern

2017-02-24 Thread Eric van Gyzen

Modified: head/contrib/netbsd-tests/lib/librt/t_sem.c


...

*sigh* I really wish people would read MAINTAINERS and include me on
CRs to contrib/netbsd-tests/ (especially since I spent a few weekends
cleaning this up to diff reduce and contribute back changes to
NetBSD).


Drat.  I totally failed to check MAINTAINERS.  Sorry, Ngie.  Thanks for 
reminding me.  I welcome any feedback.


I plan to contribute a variant this entire commit--or at least raise the 
idea--to the NetBSD folks.  If that fails, I'll at least try to 
contribute/diff-reduce the unit test.


By the way, have you considered adding a Herald rule on Phabricator?  Phab is 
not perfect, but a lot of folks use it, and the Herald rules are a very 
effective way to watch them play in one's area.


Cheers,

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


svn commit: r314205 - head/sys/compat/linuxkpi/common/include/linux

2017-02-24 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb 24 14:23:46 2017
New Revision: 314205
URL: https://svnweb.freebsd.org/changeset/base/314205

Log:
  Implement BIT_ULL() macro in the LinuxKPI.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/bitops.h

Modified: head/sys/compat/linuxkpi/common/include/linux/bitops.h
==
--- head/sys/compat/linuxkpi/common/include/linux/bitops.h  Fri Feb 24 
12:12:30 2017(r314204)
+++ head/sys/compat/linuxkpi/common/include/linux/bitops.h  Fri Feb 24 
14:23:46 2017(r314205)
@@ -37,6 +37,7 @@
 #include 
 
 #defineBIT(nr) (1UL << (nr))
+#defineBIT_ULL(nr) (1ULL << (nr))
 #ifdef __LP64__
 #defineBITS_PER_LONG   64
 #else
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314206 - head/include

2017-02-24 Thread Eric van Gyzen
Author: vangyzen
Date: Fri Feb 24 14:37:55 2017
New Revision: 314206
URL: https://svnweb.freebsd.org/changeset/base/314206

Log:
  Guard sem_clockwait_np() declaration with __BSD_VISIBLE
  
  This is a POSIX header file, so keep the namespace clean.
  
  Reported by:  kib
  MFC after:13 days
  X-MFC with:   r314179
  Sponsored by: Dell EMC

Modified:
  head/include/semaphore.h

Modified: head/include/semaphore.h
==
--- head/include/semaphore.hFri Feb 24 14:23:46 2017(r314205)
+++ head/include/semaphore.hFri Feb 24 14:37:55 2017(r314206)
@@ -59,8 +59,10 @@ int   sem_init(sem_t *, int, unsigned int
 sem_t  *sem_open(const char *, int, ...);
 int sem_post(sem_t *);
 int sem_timedwait(sem_t * __restrict, const struct timespec * __restrict);
+#if __BSD_VISIBLE
 int sem_clockwait_np(sem_t * __restrict, __clockid_t, int,
const struct timespec *, struct timespec *);
+#endif
 int sem_trywait(sem_t *);
 int sem_unlink(const char *);
 int sem_wait(sem_t *);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314179 - in head: contrib/netbsd-tests/lib/librt include lib/libc/gen lib/libc/include share/man/man3 sys/kern

2017-02-24 Thread Eric van Gyzen

On 02/24/2017 02:27, Konstantin Belousov wrote:

On Thu, Feb 23, 2017 at 07:36:39PM +, Eric van Gyzen wrote:

+int sem_clockwait_np(sem_t * __restrict, __clockid_t, int,
+   const struct timespec *, struct timespec *);

I argue that semaphore.h is POSIX include file and the declaration of
sem_clockwait_np(), despite being in implementation (non-portable)
namespace, still should be braced with #if __BSD_VISIBLE.


Good idea.  I didn't think of that.  Thanks for noticing.

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


svn commit: r314207 - head/sys/compat/linuxkpi/common/include/linux

2017-02-24 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb 24 14:40:15 2017
New Revision: 314207
URL: https://svnweb.freebsd.org/changeset/base/314207

Log:
  Implement srcu_dereference() macro in the LinuxKPI.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/srcu.h

Modified: head/sys/compat/linuxkpi/common/include/linux/srcu.h
==
--- head/sys/compat/linuxkpi/common/include/linux/srcu.hFri Feb 24 
14:37:55 2017(r314206)
+++ head/sys/compat/linuxkpi/common/include/linux/srcu.hFri Feb 24 
14:40:15 2017(r314207)
@@ -34,6 +34,8 @@ struct srcu_struct {
struct ck_epoch_record *ss_epoch_record;
 };
 
+#definesrcu_dereference(ptr,srcu)  ((__typeof(*(ptr)) *)(ptr))
+
 /* prototypes */
 
 extern int srcu_read_lock(struct srcu_struct *);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314179 - in head: contrib/netbsd-tests/lib/librt include lib/libc/gen lib/libc/include share/man/man3 sys/kern

2017-02-24 Thread Alexey Dokuchaev
On Fri, Feb 24, 2017 at 08:22:21AM -0600, Eric van Gyzen wrote:
> By the way, have you considered adding a Herald rule on Phabricator?
> Phab is not perfect, but a lot of folks use it, and the Herald rules
> are a very effective way to watch them play in one's area.

+1, we need more Herald rules to make Phabricator more efficient.  Of
course there are #manpages or #network groups, but often it is a bit
hard to come up with whom you'd want to place on the review list (like
if MAINTAINERS does not mention who's responsible and/or willing to
review the code you touch, and obviously you don't want to annoy some
random people just because you think they are technically qualified
enough or have required domain knowledge).  Sending "Hey check this out
guys, D" emails on e.g. -hackers@ is not a good option either (as
it would annoy even more people).

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


svn commit: r314208 - head/sys/dev/isp

2017-02-24 Thread Alexander Motin
Author: mav
Date: Fri Feb 24 14:48:17 2017
New Revision: 314208
URL: https://svnweb.freebsd.org/changeset/base/314208

Log:
  Respecting r314204 tighten ATIO cleanup requirements.
  
  Every ATIO must complete with either successfully sent status or XPT_ABORT.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/isp/isp_freebsd.c

Modified: head/sys/dev/isp/isp_freebsd.c
==
--- head/sys/dev/isp/isp_freebsd.c  Fri Feb 24 14:40:15 2017
(r314207)
+++ head/sys/dev/isp/isp_freebsd.c  Fri Feb 24 14:48:17 2017
(r314208)
@@ -2289,6 +2289,8 @@ isp_handle_platform_ctio(ispsoftc_t *isp
return;
}
if (ct->ct_nphdl == CT_HBA_RESET) {
+   sentstatus = (ccb->ccb_h.flags & CAM_SEND_STATUS) &&
+   (atp->sendst == 0);
failure = CAM_UNREC_HBA_ERROR;
} else {
sentstatus = ct->ct_flags & CT7_SENDSTATUS;
@@ -2311,6 +2313,8 @@ isp_handle_platform_ctio(ispsoftc_t *isp
return;
}
if (ct->ct_status == CT_HBA_RESET) {
+   sentstatus = (ccb->ccb_h.flags & CAM_SEND_STATUS) &&
+   (atp->sendst == 0);
failure = CAM_UNREC_HBA_ERROR;
} else {
sentstatus = ct->ct_flags & CT2_SENDSTATUS;
@@ -2356,9 +2360,10 @@ isp_handle_platform_ctio(ispsoftc_t *isp
}
 
/*
-* If we sent status or error happened, we are done with this ATIO.
+* We are done with this ATIO if we successfully sent status.
+* In all other cases expect either another CTIO or XPT_ABORT.
 */
-   if (sentstatus || !ok)
+   if (ok && sentstatus)
isp_put_atpd(isp, bus, atp);
 
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314207 - head/sys/compat/linuxkpi/common/include/linux

2017-02-24 Thread Mateusz Guzik
On Fri, Feb 24, 2017 at 02:40:15PM +, Hans Petter Selasky wrote:
> Author: hselasky
> Date: Fri Feb 24 14:40:15 2017
> New Revision: 314207
> URL: https://svnweb.freebsd.org/changeset/base/314207
> 
> Log:
>   Implement srcu_dereference() macro in the LinuxKPI.
>   
>   MFC after:  1 week
>   Sponsored by:   Mellanox Technologies
> 
> Modified:
>   head/sys/compat/linuxkpi/common/include/linux/srcu.h
> 
> Modified: head/sys/compat/linuxkpi/common/include/linux/srcu.h
> ==
> --- head/sys/compat/linuxkpi/common/include/linux/srcu.h  Fri Feb 24 
> 14:37:55 2017(r314206)
> +++ head/sys/compat/linuxkpi/common/include/linux/srcu.h  Fri Feb 24 
> 14:40:15 2017(r314207)
> @@ -34,6 +34,8 @@ struct srcu_struct {
>   struct ck_epoch_record *ss_epoch_record;
>  };
>  
> +#define  srcu_dereference(ptr,srcu)  ((__typeof(*(ptr)) *)(ptr))
> +

Should not this cast to volatile and read through that?

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


svn commit: r314209 - head/sys/dev/iwm

2017-02-24 Thread Adrian Chadd
Author: adrian
Date: Fri Feb 24 15:17:43 2017
New Revision: 314209
URL: https://svnweb.freebsd.org/changeset/base/314209

Log:
  [iwm] add if_iwm_fw.c.

Added:
  head/sys/dev/iwm/if_iwm_fw.c   (contents, props changed)
  head/sys/dev/iwm/if_iwm_fw.h   (contents, props changed)

Added: head/sys/dev/iwm/if_iwm_fw.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/iwm/if_iwm_fw.cFri Feb 24 15:17:43 2017
(r314209)
@@ -0,0 +1,341 @@
+/*-
+ * Based on BSD-licensed source modules in the Linux iwlwifi driver,
+ * which were used as the reference documentation for this implementation.
+ *
+ * Driver version we are currently based off of is
+ * Linux 4.7.3 (tag id d7f6728f57e3ecbb7ef34eb7d9f564d514775d75)
+ *
+ ***
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless 
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ *  * 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.
+ *  * Neither the name Intel Corporation nor the names of its
+ *contributors may be used to endorse or promote products derived
+ *from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 COPYRIGHT
+ * OWNER OR CONTRIBUTORS 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 
+__FBSDID("$FreeBSD$");
+
+#include "opt_wlan.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+void
+iwm_free_fw_paging(struct iwm_softc *sc)
+{
+   int i;
+
+   if (sc->fw_paging_db[0].fw_paging_block.vaddr == NULL)
+   return;
+
+   for (i = 0; i < IWM_NUM_OF_FW_PAGING_BLOCKS; i++) {
+   iwm_dma_contig_free(&sc->fw_paging_db[i].fw_paging_block);
+   }
+
+   memset(sc->fw_paging_db, 0, sizeof(sc->fw_paging_db));
+}
+
+static int
+iwm_fill_paging_mem(struct iwm_softc *sc, const struct iwm_fw_sects *image)
+{
+   int sec_idx, idx;
+   uint32_t offset = 0;
+
+   /*
+* find where is the pagi

Re: svn commit: r314207 - head/sys/compat/linuxkpi/common/include/linux

2017-02-24 Thread Hans Petter Selasky

On 02/24/17 16:06, Mateusz Guzik wrote:

On Fri, Feb 24, 2017 at 02:40:15PM +, Hans Petter Selasky wrote:

Author: hselasky
Date: Fri Feb 24 14:40:15 2017
New Revision: 314207
URL: https://svnweb.freebsd.org/changeset/base/314207

Log:
  Implement srcu_dereference() macro in the LinuxKPI.

  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/srcu.h

Modified: head/sys/compat/linuxkpi/common/include/linux/srcu.h
==
--- head/sys/compat/linuxkpi/common/include/linux/srcu.hFri Feb 24 
14:37:55 2017(r314206)
+++ head/sys/compat/linuxkpi/common/include/linux/srcu.hFri Feb 24 
14:40:15 2017(r314207)
@@ -34,6 +34,8 @@ struct srcu_struct {
struct ck_epoch_record *ss_epoch_record;
 };

+#definesrcu_dereference(ptr,srcu)  ((__typeof(*(ptr)) *)(ptr))
+


Should not this cast to volatile and read through that?



Hi,

This macro should only be used inside a srcu_read_lock() and 
srcu_read_unlock() section and then volatile is not part of the game I 
think. The srcu argument is passed so that checks can be added to assert 
this.


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


Re: svn commit: r314189 - head/lib/libcam

2017-02-24 Thread Ian Lepore
On Fri, 2017-02-24 at 06:24 +, Ngie Cooper wrote:
> Author: ngie
> Date: Fri Feb 24 06:24:39 2017
> New Revision: 314189
> URL: https://svnweb.freebsd.org/changeset/base/314189
> 
> Log:
>   Fix up NULL/'\0' uses and fix 2 derefs after NULL
>   
>   MFC after:  2 weeks
>   Reported by:Coverity
>   CID:1018898, 1018899
>   Differential Revision:  https://reviews.freebsd.org/D6142
>   Sponsored by:   Dell EMC Isilon
> 
> Modified:
>   head/lib/libcam/scsi_cmdparse.c
> 
> Modified: head/lib/libcam/scsi_cmdparse.c
> =
> =
> --- head/lib/libcam/scsi_cmdparse.c   Fri Feb 24 01:39:12 2017
> (r314188)
> +++ head/lib/libcam/scsi_cmdparse.c   Fri Feb 24 06:24:39 2017
> (r314189)
> @@ -128,14 +128,14 @@ do_buff_decode(u_int8_t *buff, size_t le
>   *(va_arg(*ap, int *)) = (ARG); \
>   assigned++; \
>   } \
> - field_name[0] = 0; \
> + field_name[0] = '\0'; \

Is coverity seriously complaining about using 0 instead of '\0'?  What
possible *real* benefit (not just shutting up coverity) does this churn
bring?

-- Ian

>   suppress = 0; \
>   } while (0)
>  
>   u_char bits = 0;/* For bit fields */
>   int shift = 0;  /* Bits already shifted out */
>   suppress = 0;
> - field_name[0] = 0;
> + field_name[0] = '\0';
>  
>   while (!done) {
>   switch(letter = *fmt) {
> @@ -169,9 +169,9 @@ do_buff_decode(u_int8_t *buff, size_t le
>  
>   fmt++;
>   }
> - if (fmt)
> + if (*fmt == '\0')
>   fmt++;  /* Skip '}' */
> - field_name[i] = 0;
> + field_name[i] = '\0';
>   break;
>   }
>  
> @@ -255,7 +255,7 @@ do_buff_decode(u_int8_t *buff, size_t le
>   break;
>   }
>   if (!suppress) {
> - if (arg_put)
> + if (arg_put != NULL)
>   (*arg_put)(puthook,
>   (letter == 't' ? 'b' :
> letter),
>   &buff[ind], width,
> field_name);
> @@ -268,7 +268,7 @@ do_buff_decode(u_int8_t *buff, size_t le
>   for (p = dest +
> width - 1;
>   p >= dest && *p
> == ' ';
>   p--)
> - *p = 0;
> + *p = '\0';
>   }
>   }
>   assigned++;
> @@ -379,22 +379,22 @@ next_field(const char **pp, char *fmt, i
>   field_size = 8; /* Default to byte field
> type... */
>   *fmt = 'i';
>   field_width = 1;/* 1 byte wide */
> - if (name)
> - *name = 0;
> + if (name != NULL)
> + *name = '\0';
>  
>   state = BETWEEN_FIELDS;
>  
>   while (state != DONE) {
>   switch(state) {
>   case BETWEEN_FIELDS:
> - if (*p == 0)
> + if (*p == '\0')
>   state = DONE;
>   else if (isspace(*p))
>   p++;
>   else if (*p == '#') {
>   while (*p && *p != '\n')
>   p++;
> - if (p)
> + if (*p != '\0')
>   p++;
>   } else if (*p == '{') {
>   int i = 0;
> @@ -410,7 +410,7 @@ next_field(const char **pp, char *fmt, i
>   }
>  
>   if(name && i < n_name)
> - name[i] = 0;
> + name[i] = '\0';
>  
>   if (*p == '}')
>   p++;
> @@ -568,7 +568,7 @@ do_encode(u_char *buff, size_t vec_max, 
>   if (suppress)
>   value = 0;
>   else
> - value = arg_get ?
> + value = arg_get != NULL ?
>   (*arg_get)(gethook,
> field_name) :
>   va_arg(*ap, int);
>   }
> @@ -672,8 +672,8 @@ csio_decode(struct ccb_scsiio *csio, con
>  
>   va_start(ap, fmt);
>  
> - retval = do_buff_decode(csio->data_ptr, (size_t)csio-
> >dxfer_len, 0, 0,
> -  fmt, &ap);
> + re

Re: svn commit: r314192 - in head/sys: conf dev/iwm modules/iwm

2017-02-24 Thread Adrian Chadd
Fixed!


-a


On 24 February 2017 at 06:10, Cy Schubert  wrote:
> In message <201702240707.v1o77was011...@repo.freebsd.org>, Adrian Chadd
> writes:
>> Author: adrian
>> Date: Fri Feb 24 07:07:58 2017
>> New Revision: 314192
>> URL: https://svnweb.freebsd.org/changeset/base/314192
>>
>> Log:
>>   [iwm] Add support for Firmware paging, needed for newer 8000C firmware.
>>
>>   * Uses the IWM_FW_PAGING_BLOCK_CMD firmware command to tell the firmware
>> what memory ranges to use for paging.
>>
>>   Obtained from:  dragonflybsd.git 8a5b199964f8e7bdb00039f0b48817a01b402f
>> 18
>>
>> Modified:
>>   head/sys/conf/files
>>   head/sys/dev/iwm/if_iwm.c
>>   head/sys/dev/iwm/if_iwm_debug.h
>>   head/sys/dev/iwm/if_iwmreg.h
>>   head/sys/dev/iwm/if_iwmvar.h
>>   head/sys/modules/iwm/Makefile
>
> Looks like you forgot svn add.
>
> --- all_subdir_iwm ---
> make[4]: make[4]: don't know how to make if_iwm_fw.c. Stop
>
> make[4]: stopped in /opt/src/svn-current/sys/modules/iwm
> *** [all_subdir_iwm] Error code 2
>
> make[3]: stopped in /opt/src/svn-current/sys/modules
>
>
> --
> Cheers,
> Cy Schubert 
> FreeBSD UNIX: Web:  http://www.FreeBSD.org
>
> The need of the many outweighs the greed of the few.
>
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314211 - in head/sys: dev/acpica kern sys x86/x86

2017-02-24 Thread Konstantin Belousov
Author: kib
Date: Fri Feb 24 16:11:55 2017
New Revision: 314211
URL: https://svnweb.freebsd.org/changeset/base/314211

Log:
  Remove cpu_deepest_sleep variable.
  
  On Core2 and older Intel CPUs, where TSC stops in C2, system does not
  allow C2 entrance if timecounter hardware is TSC.  This is done by
  tc_windup() which tests for TC_FLAGS_C2STOP flag of the new
  timecounter and increases cpu_disable_c2_sleep if flag is set.  Right
  now init_TSC_tc() only sets the flag if cpu_deepest_sleep >= 2, but
  TSC is initialized too early for this variable to be set by
  acpi_cpu.c.
  
  There is no reason to require that ACPI reported C2 and deeper states
  to set TC_FLAGS_C2STOP, so remove cpu_deepest_sleep test from
  init_TSC_tc() condition.  And since this is the only use of the
  variable, remove it at all.
  
  Reported and submitted by:Jia-Shiun Li 
  Suggested by: jhb
  MFC after:2 weeks

Modified:
  head/sys/dev/acpica/acpi_cpu.c
  head/sys/kern/kern_clocksource.c
  head/sys/sys/systm.h
  head/sys/x86/x86/tsc.c

Modified: head/sys/dev/acpica/acpi_cpu.c
==
--- head/sys/dev/acpica/acpi_cpu.c  Fri Feb 24 16:02:01 2017
(r314210)
+++ head/sys/dev/acpica/acpi_cpu.c  Fri Feb 24 16:11:55 2017
(r314211)
@@ -703,7 +703,6 @@ acpi_cpu_generic_cx_probe(struct acpi_cp
 sc->cpu_non_c2 = sc->cpu_cx_count;
 sc->cpu_non_c3 = sc->cpu_cx_count;
 sc->cpu_cx_count++;
-cpu_deepest_sleep = 1;
 
 /* 
  * The spec says P_BLK must be 6 bytes long.  However, some systems
@@ -729,7 +728,6 @@ acpi_cpu_generic_cx_probe(struct acpi_cp
cx_ptr++;
sc->cpu_non_c3 = sc->cpu_cx_count;
sc->cpu_cx_count++;
-   cpu_deepest_sleep = 2;
}
 }
 if (sc->cpu_p_blk_len < 6)
@@ -746,7 +744,6 @@ acpi_cpu_generic_cx_probe(struct acpi_cp
cx_ptr->trans_lat = AcpiGbl_FADT.C3Latency;
cx_ptr++;
sc->cpu_cx_count++;
-   cpu_deepest_sleep = 3;
}
 }
 }
@@ -831,7 +828,6 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *s
 cx_ptr->type = ACPI_STATE_C0;
 cx_ptr++;
 sc->cpu_cx_count++;
-cpu_deepest_sleep = 1;
 
 /* Set up all valid states. */
 for (i = 0; i < count; i++) {
@@ -884,8 +880,6 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *s
continue;
case ACPI_STATE_C2:
sc->cpu_non_c3 = sc->cpu_cx_count;
-   if (cpu_deepest_sleep < 2)
-   cpu_deepest_sleep = 2;
break;
case ACPI_STATE_C3:
default:
@@ -894,8 +888,7 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *s
 "acpi_cpu%d: C3[%d] not available.\n",
 device_get_unit(sc->cpu_dev), i));
continue;
-   } else
-   cpu_deepest_sleep = 3;
+   }
break;
}
 

Modified: head/sys/kern/kern_clocksource.c
==
--- head/sys/kern/kern_clocksource.cFri Feb 24 16:02:01 2017
(r314210)
+++ head/sys/kern/kern_clocksource.cFri Feb 24 16:11:55 2017
(r314211)
@@ -54,7 +54,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-intcpu_deepest_sleep = 0;  /* Deepest Cx state available. 
*/
 intcpu_disable_c2_sleep = 0; /* Timer dies in C2. */
 intcpu_disable_c3_sleep = 0; /* Timer dies in C3. */
 

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hFri Feb 24 16:02:01 2017(r314210)
+++ head/sys/sys/systm.hFri Feb 24 16:11:55 2017(r314211)
@@ -321,7 +321,6 @@ sbintime_t  cpu_idleclock(void);
 void   cpu_activeclock(void);
 void   cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt);
 void   cpu_et_frequency(struct eventtimer *et, uint64_t newfreq);
-extern int cpu_deepest_sleep;
 extern int cpu_disable_c2_sleep;
 extern int cpu_disable_c3_sleep;
 

Modified: head/sys/x86/x86/tsc.c
==
--- head/sys/x86/x86/tsc.c  Fri Feb 24 16:02:01 2017(r314210)
+++ head/sys/x86/x86/tsc.c  Fri Feb 24 16:11:55 2017(r314211)
@@ -542,7 +542,7 @@ init_TSC_tc(void)
 * result incorrect runtimes for kernel idle threads (but not
 * for any non-idle threads).
 */
-   if (cpu_deepest_sleep >= 2 && cpu_vendor_id == CPU_VENDOR_INTEL &&
+   if (cpu_vendor_id == CPU_VENDOR_INTEL &&
(amd_pminfo & AMDPM_TSC_INVARIANT) == 0) {
tsc_timecounter.tc_flags |= TC_FLAGS_C2STOP;
if (bootverbose)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-s

svn commit: r314212 - head/sys/dev/uart

2017-02-24 Thread Ruslan Bukin
Author: br
Date: Fri Feb 24 16:37:35 2017
New Revision: 314212
URL: https://svnweb.freebsd.org/changeset/base/314212

Log:
  Use correct macro for Synopsys UART driver declaration.

Modified:
  head/sys/dev/uart/uart_dev_snps.c

Modified: head/sys/dev/uart/uart_dev_snps.c
==
--- head/sys/dev/uart/uart_dev_snps.c   Fri Feb 24 16:11:55 2017
(r314211)
+++ head/sys/dev/uart/uart_dev_snps.c   Fri Feb 24 16:37:35 2017
(r314212)
@@ -104,7 +104,7 @@ static struct ofw_compat_data compat_dat
{ "snps,dw-apb-uart",   (uintptr_t)&uart_snps_class },
{ NULL, (uintptr_t)NULL }
 };
-UART_FDT_CLASS(compat_data);
+UART_FDT_CLASS_AND_DEVICE(compat_data);
 
 #ifdef EXT_RESOURCES
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314213 - head/sys/boot/geli

2017-02-24 Thread Allan Jude
Author: allanjude
Date: Fri Feb 24 16:52:57 2017
New Revision: 314213
URL: https://svnweb.freebsd.org/changeset/base/314213

Log:
  Remove control+r handling from geliboot's pwgets()
  
  pwgets() is based on ngets() from libstand, which includes a feature
  that is not wanted in a very of the function designed for password
  handling.
  
  Pressing control+r echos out the entered string
  
  This commit removes that feature from pwgets()
  
  PR:   217298
  Reported by:  ehaupt
  Reviewed by:  kristof, tsoome, ehaupt
  Sponsored by: ScaleEngine Inc.
  Differential Revision:https://reviews.freebsd.org/D9782

Modified:
  head/sys/boot/geli/pwgets.c

Modified: head/sys/boot/geli/pwgets.c
==
--- head/sys/boot/geli/pwgets.c Fri Feb 24 16:37:35 2017(r314212)
+++ head/sys/boot/geli/pwgets.c Fri Feb 24 16:52:57 2017(r314213)
@@ -60,14 +60,6 @@ pwgets(char *buf, int n)
putchar('\b');
}
break;
-   case 'r'&037: {
-   char *p;
-
-   putchar('\n');
-   for (p = buf; p < lp; ++p)
-   putchar(*p);
-   break;
-   }
case 'u'&037:
case 'w'&037:
lp = buf;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314214 - head/sys/compat/linuxkpi/common/include/linux

2017-02-24 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb 24 17:03:14 2017
New Revision: 314214
URL: https://svnweb.freebsd.org/changeset/base/314214

Log:
  Prototype device structure to ensure LinuxKPI header file can be
  included standalone.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/device.h

Modified: head/sys/compat/linuxkpi/common/include/linux/device.h
==
--- head/sys/compat/linuxkpi/common/include/linux/device.h  Fri Feb 24 
16:52:57 2017(r314213)
+++ head/sys/compat/linuxkpi/common/include/linux/device.h  Fri Feb 24 
17:03:14 2017(r314214)
@@ -49,6 +49,8 @@
 enum irqreturn { IRQ_NONE = 0, IRQ_HANDLED, IRQ_WAKE_THREAD, };
 typedef enum irqreturn irqreturn_t;
 
+struct device;
+
 struct class {
const char  *name;
struct module   *owner;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314215 - head/sys/compat/linuxkpi/common/include/linux

2017-02-24 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb 24 17:36:55 2017
New Revision: 314215
URL: https://svnweb.freebsd.org/changeset/base/314215

Log:
  Implement more string functions in the LinuxKPI.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/string.h

Modified: head/sys/compat/linuxkpi/common/include/linux/string.h
==
--- head/sys/compat/linuxkpi/common/include/linux/string.h  Fri Feb 24 
17:03:14 2017(r314214)
+++ head/sys/compat/linuxkpi/common/include/linux/string.h  Fri Feb 24 
17:36:55 2017(r314215)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,29 +31,111 @@
 #ifndef_LINUX_STRING_H_
 #define_LINUX_STRING_H_
 
+#include 
+
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
 #definestrnicmp(...) strncasecmp(__VA_ARGS__)
 
+static inline int
+match_string(const char *const *table, int n, const char *key)
+{
+   int i;
+
+   for (i = 0; i != n && table[i] != NULL; i++) {
+   if (strcmp(table[i], key) == 0)
+   return (i);
+   }
+   return (-EINVAL);
+}
+
+static inline void *
+memdup_user(const void *ptr, size_t len)
+{
+   void *retval;
+   int error;
+
+   retval = malloc(len, M_KMALLOC, M_WAITOK);
+   error = linux_copyin(ptr, retval, len);
+   if (error != 0) {
+   free(retval, M_KMALLOC);
+   return (ERR_PTR(error));
+   }
+   return (retval);
+}
+
 static inline void *
 kmemdup(const void *src, size_t len, gfp_t gfp)
 {
void *dst;
 
dst = kmalloc(len, gfp);
-   if (dst)
+   if (dst != NULL)
memcpy(dst, src, len);
return (dst);
 }
 
+static inline char *
+kstrdup(const char *string, gfp_t gfp)
+{
+   char *retval;
+   size_t len;
+
+   len = strlen(string) + 1;
+   retval = kmalloc(len, gfp);
+   if (retval != NULL)
+   memcpy(retval, string, len);
+   return (retval);
+}
+
+static inline char *
+kstrndup(const char *string, size_t len, gfp_t gfp)
+{
+   char *retval;
+
+   retval = kmalloc(len + 1, gfp);
+   if (retval != NULL)
+   strncpy(retval, string, len);
+   return (retval);
+}
+
 static inline const char *
 kstrdup_const(const char *src, gfp_t gfp)
 {
return (kmemdup(src, strlen(src) + 1, gfp));
 }
 
-#endif /* _LINUX_STRING_H_ */
+static inline char *
+skip_spaces(const char *str)
+{
+   while (isspace(*str))
+   ++str;
+   return (__DECONST(char *, str));
+}
+
+static inline void *
+memchr_inv(const void *start, int c, size_t length)
+{
+   const u8 *ptr;
+   const u8 *end;
+   u8 ch;
+
+   ch = c;
+   ptr = start;
+   end = ptr + length;
+
+   while (ptr != end) {
+   if (*ptr != ch)
+   return (__DECONST(void *, ptr));
+   ptr++;
+   }
+   return (NULL);
+}
+
+#endif /* _LINUX_STRING_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314216 - head/sys/x86/x86

2017-02-24 Thread Jonathan T. Looney
Author: jtl
Date: Fri Feb 24 18:56:00 2017
New Revision: 314216
URL: https://svnweb.freebsd.org/changeset/base/314216

Log:
  We have seen several cases recently where we appear to get a double-fault:
  We have an original panic. Then, instead of writing the core to the dump
  device, the kernel has a second panic: "smp_targeted_tlb_shootdown:
  interrupts disabled". This change is an attempt to fix that second panic.
  
  When the other CPUs are stopped, we can't notify them of the TLB shootdown,
  so we skip that operation. However, when the CPUs come back up, we
  invalidate the TLB to ensure they correctly observe any changes to the
  page mappings.
  
  Reviewed by:  kib
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D9786

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Fri Feb 24 17:36:55 2017(r314215)
+++ head/sys/x86/x86/mp_x86.c   Fri Feb 24 18:56:00 2017(r314216)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #ifdef GPROF 
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
@@ -1269,6 +1270,12 @@ cpustop_handler_post(u_int cpu)
CPU_CLR_ATOMIC(cpu, &started_cpus);
CPU_CLR_ATOMIC(cpu, &stopped_cpus);
 
+   /*
+* We don't broadcast TLB invalidations to other CPUs when they are
+* stopped. Hence, we clear the TLB before resuming.
+*/
+   invltlb_glob();
+
 #if defined(__amd64__) && defined(DDB)
amd64_db_resume_dbreg();
 #endif
@@ -1427,6 +1434,10 @@ smp_targeted_tlb_shootdown(cpuset_t mask
uint32_t generation;
int cpu;
 
+   /* It is not necessary to signal other CPUs while in the debugger. */
+   if (kdb_active || panicstr != NULL)
+   return;
+
/*
 * Check for other cpus.  Return if none.
 */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314209 - head/sys/dev/iwm

2017-02-24 Thread Adrian Chadd
[snip]

(adrian ran out of coffee at home three days ago.)



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


svn commit: r314217 - in head/sys: amd64/linux amd64/linux32 compat/linux i386/linux

2017-02-24 Thread Mahdi Mokhtari
Author: mmokhi (ports committer)
Date: Fri Feb 24 19:22:17 2017
New Revision: 314217
URL: https://svnweb.freebsd.org/changeset/base/314217

Log:
  Add linux_preadv() and linux_pwritev() syscalls to Linuxulator.
  
  Reviewed by:  dchagin
  Approved by:  dchagin, trasz (src committers)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D9722

Modified:
  head/sys/amd64/linux/linux_dummy.c
  head/sys/amd64/linux32/linux32_dummy.c
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/compat/linux/linux_file.c
  head/sys/i386/linux/linux_dummy.c

Modified: head/sys/amd64/linux/linux_dummy.c
==
--- head/sys/amd64/linux/linux_dummy.c  Fri Feb 24 18:56:00 2017
(r314216)
+++ head/sys/amd64/linux/linux_dummy.c  Fri Feb 24 19:22:17 2017
(r314217)
@@ -110,9 +110,6 @@ DUMMY(timerfd_gettime);
 /* linux 2.6.27: */
 DUMMY(signalfd4);
 DUMMY(inotify_init1);
-/* linux 2.6.30: */
-DUMMY(preadv);
-DUMMY(pwritev);
 /* linux 2.6.31: */
 DUMMY(perf_event_open);
 /* linux 2.6.38: */

Modified: head/sys/amd64/linux32/linux32_dummy.c
==
--- head/sys/amd64/linux32/linux32_dummy.c  Fri Feb 24 18:56:00 2017
(r314216)
+++ head/sys/amd64/linux32/linux32_dummy.c  Fri Feb 24 19:22:17 2017
(r314217)
@@ -110,9 +110,6 @@ DUMMY(timerfd_gettime);
 /* linux 2.6.27: */
 DUMMY(signalfd4);
 DUMMY(inotify_init1);
-/* linux 2.6.30: */
-DUMMY(preadv);
-DUMMY(pwritev);
 /* linux 2.6.31: */
 DUMMY(perf_event_open);
 /* linux 2.6.33: */

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cFri Feb 24 18:56:00 2017
(r314216)
+++ head/sys/amd64/linux32/linux32_machdep.cFri Feb 24 19:22:17 2017
(r314217)
@@ -241,6 +241,52 @@ linux_writev(struct thread *td, struct l
return (error);
 }
 
+int
+linux_preadv(struct thread *td, struct linux_preadv_args *uap)
+{
+   struct uio *auio;
+   int error;
+   off_t offset;
+
+   error = linux32_copyinuio((struct l_iovec32 *)uap->vec,
+   uap->vlen, &auio);
+   if (error)
+   return (error);
+   /*
+* According http://man7.org/linux/man-pages/man2/preadv.2.html#NOTES
+* pos_l and pos_h, respectively, contain the
+* low order and high order 32 bits of offset.
+*/
+   offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
+   (sizeof(offset) * 4)) | uap->pos_l;
+   error = kern_preadv(td, uap->fd, auio, offset);
+   free(auio, M_IOV);
+   return (error);
+}
+
+int
+linux_pwritev(struct thread *td, struct linux_pwritev_args *uap)
+{
+   struct uio *auio;
+   int error;
+   off_t offset;
+
+   error = linux32_copyinuio((struct l_iovec32 *)uap->vec,
+   uap->vlen, &auio);
+   if (error)
+   return (error);
+   /*
+* According http://man7.org/linux/man-pages/man2/pwritev.2.html#NOTES
+* pos_l and pos_h, respectively, contain the
+* low order and high order 32 bits of offset.
+*/
+   offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
+   (sizeof(offset) * 4)) | uap->pos_l;
+   error = kern_pwritev(td, uap->fd, auio, offset);
+   free(auio, M_IOV);
+   return (error);
+}
+
 struct l_ipc_kludge {
l_uintptr_t msgp;
l_long msgtyp;

Modified: head/sys/compat/linux/linux_file.c
==
--- head/sys/compat/linux/linux_file.c  Fri Feb 24 18:56:00 2017
(r314216)
+++ head/sys/compat/linux/linux_file.c  Fri Feb 24 19:22:17 2017
(r314217)
@@ -1027,6 +1027,52 @@ linux_pwrite(struct thread *td, struct l
return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
 }
 
+#if !(defined(__amd64__) && defined(COMPAT_LINUX32))
+int
+linux_preadv(struct thread *td, struct linux_preadv_args *uap)
+{
+   struct uio *auio;
+   int error;
+   off_t offset;
+
+   error = copyinuio(uap->vec, uap->vlen, &auio);
+   if (error)
+   return (error);
+   /*
+* According http://man7.org/linux/man-pages/man2/preadv.2.html#NOTES
+* pos_l and pos_h, respectively, contain the
+* low order and high order 32 bits of offset.
+*/
+   offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
+   (sizeof(offset) * 4)) | uap->pos_l;
+   error = kern_preadv(td, uap->fd, auio, offset);
+   free(auio, M_IOV);
+   return (error);
+}
+
+int
+linux_pwritev(struct thread *td, struct linux_pwritev_args *uap)
+{
+   struct uio *auio;
+   int error;
+   off_t offset;
+
+   error = copyinuio(uap->vec, uap->vlen, &auio);
+   if (error)
+   return (error);
+   /*
+  

svn commit: r314218 - in head/sys: amd64/linux amd64/linux32 compat/linux i386/linux

2017-02-24 Thread Dmitry Chagin
Author: dchagin
Date: Fri Feb 24 19:47:27 2017
New Revision: 314218
URL: https://svnweb.freebsd.org/changeset/base/314218

Log:
  Revert r314217. Commit is not match that I have approved.

Modified:
  head/sys/amd64/linux/linux_dummy.c
  head/sys/amd64/linux32/linux32_dummy.c
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/compat/linux/linux_file.c
  head/sys/i386/linux/linux_dummy.c

Modified: head/sys/amd64/linux/linux_dummy.c
==
--- head/sys/amd64/linux/linux_dummy.c  Fri Feb 24 19:22:17 2017
(r314217)
+++ head/sys/amd64/linux/linux_dummy.c  Fri Feb 24 19:47:27 2017
(r314218)
@@ -110,6 +110,9 @@ DUMMY(timerfd_gettime);
 /* linux 2.6.27: */
 DUMMY(signalfd4);
 DUMMY(inotify_init1);
+/* linux 2.6.30: */
+DUMMY(preadv);
+DUMMY(pwritev);
 /* linux 2.6.31: */
 DUMMY(perf_event_open);
 /* linux 2.6.38: */

Modified: head/sys/amd64/linux32/linux32_dummy.c
==
--- head/sys/amd64/linux32/linux32_dummy.c  Fri Feb 24 19:22:17 2017
(r314217)
+++ head/sys/amd64/linux32/linux32_dummy.c  Fri Feb 24 19:47:27 2017
(r314218)
@@ -110,6 +110,9 @@ DUMMY(timerfd_gettime);
 /* linux 2.6.27: */
 DUMMY(signalfd4);
 DUMMY(inotify_init1);
+/* linux 2.6.30: */
+DUMMY(preadv);
+DUMMY(pwritev);
 /* linux 2.6.31: */
 DUMMY(perf_event_open);
 /* linux 2.6.33: */

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cFri Feb 24 19:22:17 2017
(r314217)
+++ head/sys/amd64/linux32/linux32_machdep.cFri Feb 24 19:47:27 2017
(r314218)
@@ -241,52 +241,6 @@ linux_writev(struct thread *td, struct l
return (error);
 }
 
-int
-linux_preadv(struct thread *td, struct linux_preadv_args *uap)
-{
-   struct uio *auio;
-   int error;
-   off_t offset;
-
-   error = linux32_copyinuio((struct l_iovec32 *)uap->vec,
-   uap->vlen, &auio);
-   if (error)
-   return (error);
-   /*
-* According http://man7.org/linux/man-pages/man2/preadv.2.html#NOTES
-* pos_l and pos_h, respectively, contain the
-* low order and high order 32 bits of offset.
-*/
-   offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
-   (sizeof(offset) * 4)) | uap->pos_l;
-   error = kern_preadv(td, uap->fd, auio, offset);
-   free(auio, M_IOV);
-   return (error);
-}
-
-int
-linux_pwritev(struct thread *td, struct linux_pwritev_args *uap)
-{
-   struct uio *auio;
-   int error;
-   off_t offset;
-
-   error = linux32_copyinuio((struct l_iovec32 *)uap->vec,
-   uap->vlen, &auio);
-   if (error)
-   return (error);
-   /*
-* According http://man7.org/linux/man-pages/man2/pwritev.2.html#NOTES
-* pos_l and pos_h, respectively, contain the
-* low order and high order 32 bits of offset.
-*/
-   offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
-   (sizeof(offset) * 4)) | uap->pos_l;
-   error = kern_pwritev(td, uap->fd, auio, offset);
-   free(auio, M_IOV);
-   return (error);
-}
-
 struct l_ipc_kludge {
l_uintptr_t msgp;
l_long msgtyp;

Modified: head/sys/compat/linux/linux_file.c
==
--- head/sys/compat/linux/linux_file.c  Fri Feb 24 19:22:17 2017
(r314217)
+++ head/sys/compat/linux/linux_file.c  Fri Feb 24 19:47:27 2017
(r314218)
@@ -1027,52 +1027,6 @@ linux_pwrite(struct thread *td, struct l
return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
 }
 
-#if !(defined(__amd64__) && defined(COMPAT_LINUX32))
-int
-linux_preadv(struct thread *td, struct linux_preadv_args *uap)
-{
-   struct uio *auio;
-   int error;
-   off_t offset;
-
-   error = copyinuio(uap->vec, uap->vlen, &auio);
-   if (error)
-   return (error);
-   /*
-* According http://man7.org/linux/man-pages/man2/preadv.2.html#NOTES
-* pos_l and pos_h, respectively, contain the
-* low order and high order 32 bits of offset.
-*/
-   offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
-   (sizeof(offset) * 4)) | uap->pos_l;
-   error = kern_preadv(td, uap->fd, auio, offset);
-   free(auio, M_IOV);
-   return (error);
-}
-
-int
-linux_pwritev(struct thread *td, struct linux_pwritev_args *uap)
-{
-   struct uio *auio;
-   int error;
-   off_t offset;
-
-   error = copyinuio(uap->vec, uap->vlen, &auio);
-   if (error)
-   return (error);
-   /*
-* According http://man7.org/linux/man-pages/man2/pwritev.2.html#NOTES
-* pos_l and pos_h, respectively, contain the
-* low order and high order 32 bits of offset.
- 

Re: svn commit: r314218 - in head/sys: amd64/linux amd64/linux32 compat/linux i386/linux

2017-02-24 Thread mokhi
Thanks for fixing it.
I'm gonna apply correct patch soon __/\__


--
Best regards, MMokhi.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314219 - in head/sys: amd64/linux amd64/linux32 compat/linux i386/linux

2017-02-24 Thread Mahdi Mokhtari
Author: mmokhi (ports committer)
Date: Fri Feb 24 20:04:02 2017
New Revision: 314219
URL: https://svnweb.freebsd.org/changeset/base/314219

Log:
  Add linux_preadv() and linux_pwritev() syscalls to Linuxulator.
  
  Reviewed by:  dchagin
  Approved by:  dchagin, trasz (src committers)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D9722

Modified:
  head/sys/amd64/linux/linux_dummy.c
  head/sys/amd64/linux32/linux.h
  head/sys/amd64/linux32/linux32_dummy.c
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/compat/linux/linux_file.c
  head/sys/i386/linux/linux_dummy.c

Modified: head/sys/amd64/linux/linux_dummy.c
==
--- head/sys/amd64/linux/linux_dummy.c  Fri Feb 24 19:47:27 2017
(r314218)
+++ head/sys/amd64/linux/linux_dummy.c  Fri Feb 24 20:04:02 2017
(r314219)
@@ -110,9 +110,6 @@ DUMMY(timerfd_gettime);
 /* linux 2.6.27: */
 DUMMY(signalfd4);
 DUMMY(inotify_init1);
-/* linux 2.6.30: */
-DUMMY(preadv);
-DUMMY(pwritev);
 /* linux 2.6.31: */
 DUMMY(perf_event_open);
 /* linux 2.6.38: */

Modified: head/sys/amd64/linux32/linux.h
==
--- head/sys/amd64/linux32/linux.h  Fri Feb 24 19:47:27 2017
(r314218)
+++ head/sys/amd64/linux32/linux.h  Fri Feb 24 20:04:02 2017
(r314219)
@@ -663,6 +663,7 @@ struct l_user_desc {
(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
 
 struct iovec;
+struct uio;
 
 struct l_iovec32 {
uint32_tiov_base;
@@ -671,6 +672,8 @@ struct l_iovec32 {
 
 int linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt,
struct iovec **iovp, int error);
+int linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt,
+   struct uio **uiop);
 int linux_copyout_rusage(struct rusage *ru, void *uaddr);
 
 /* robust futexes */

Modified: head/sys/amd64/linux32/linux32_dummy.c
==
--- head/sys/amd64/linux32/linux32_dummy.c  Fri Feb 24 19:47:27 2017
(r314218)
+++ head/sys/amd64/linux32/linux32_dummy.c  Fri Feb 24 20:04:02 2017
(r314219)
@@ -110,9 +110,6 @@ DUMMY(timerfd_gettime);
 /* linux 2.6.27: */
 DUMMY(signalfd4);
 DUMMY(inotify_init1);
-/* linux 2.6.30: */
-DUMMY(preadv);
-DUMMY(pwritev);
 /* linux 2.6.31: */
 DUMMY(perf_event_open);
 /* linux 2.6.33: */

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cFri Feb 24 19:47:27 2017
(r314218)
+++ head/sys/amd64/linux32/linux32_machdep.cFri Feb 24 20:04:02 2017
(r314219)
@@ -144,7 +144,7 @@ linux_execve(struct thread *td, struct l
 
 CTASSERT(sizeof(struct l_iovec32) == 8);
 
-static int
+int
 linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, struct uio **uiop)
 {
struct l_iovec32 iov32;

Modified: head/sys/compat/linux/linux_file.c
==
--- head/sys/compat/linux/linux_file.c  Fri Feb 24 19:47:27 2017
(r314218)
+++ head/sys/compat/linux/linux_file.c  Fri Feb 24 20:04:02 2017
(r314219)
@@ -1028,6 +1028,62 @@ linux_pwrite(struct thread *td, struct l
 }
 
 int
+linux_preadv(struct thread *td, struct linux_preadv_args *uap)
+{
+   struct uio *auio;
+   int error;
+   off_t offset;
+
+   /*
+* According http://man7.org/linux/man-pages/man2/preadv.2.html#NOTES
+* pos_l and pos_h, respectively, contain the
+* low order and high order 32 bits of offset.
+*/
+   offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
+   (sizeof(offset) * 4)) | uap->pos_l;
+   if (offset < 0)
+   return (EINVAL);
+#ifdef COMPAT_LINUX32
+   error = linux32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio);
+#else
+   error = copyinuio(uap->vec, uap->vlen, &auio);
+#endif
+   if (error != 0)
+   return (error);
+   error = kern_preadv(td, uap->fd, auio, offset);
+   free(auio, M_IOV);
+   return (error);
+}
+
+int
+linux_pwritev(struct thread *td, struct linux_pwritev_args *uap)
+{
+   struct uio *auio;
+   int error;
+   off_t offset;
+
+   /*
+* According http://man7.org/linux/man-pages/man2/pwritev.2.html#NOTES
+* pos_l and pos_h, respectively, contain the
+* low order and high order 32 bits of offset.
+*/
+   offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
+   (sizeof(offset) * 4)) | uap->pos_l;
+   if (offset < 0)
+   return (EINVAL);
+#ifdef COMPAT_LINUX32
+   error = linux32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio);
+#else
+   error = copyinuio(uap->vec, uap->vlen, &auio);
+#endif
+   if (error != 0)
+   return (error

Re: svn commit: r314216 - head/sys/x86/x86

2017-02-24 Thread hiren panchasara
On 02/24/17 at 06:56P, Jonathan T. Looney wrote:
> Author: jtl
> Date: Fri Feb 24 18:56:00 2017
> New Revision: 314216
> URL: https://svnweb.freebsd.org/changeset/base/314216
> 
> Log:
>   We have seen several cases recently where we appear to get a double-fault:
>   We have an original panic. Then, instead of writing the core to the dump
>   device, the kernel has a second panic: "smp_targeted_tlb_shootdown:
>   interrupts disabled". This change is an attempt to fix that second panic.
>   
>   When the other CPUs are stopped, we can't notify them of the TLB shootdown,
>   so we skip that operation. However, when the CPUs come back up, we
>   invalidate the TLB to ensure they correctly observe any changes to the
>   page mappings.
>   
>   Reviewed by:kib
>   Sponsored by:   Netflix
>   Differential Revision:  https://reviews.freebsd.org/D9786

Can this be MFCd to 11?

Cheers,
Hiren


pgpaLlGRNGfLX.pgp
Description: PGP signature


Re: svn commit: r314179 - in head: contrib/netbsd-tests/lib/librt include lib/libc/gen lib/libc/include share/man/man3 sys/kern

2017-02-24 Thread Ngie Cooper (yaneurabeya)

> On Feb 24, 2017, at 6:43 AM, Alexey Dokuchaev  wrote:
> 
> On Fri, Feb 24, 2017 at 08:22:21AM -0600, Eric van Gyzen wrote:
>> By the way, have you considered adding a Herald rule on Phabricator?
>> Phab is not perfect, but a lot of folks use it, and the Herald rules
>> are a very effective way to watch them play in one's area.
> 
> +1, we need more Herald rules to make Phabricator more efficient.  Of
> course there are #manpages or #network groups, but often it is a bit
> hard to come up with whom you'd want to place on the review list (like
> if MAINTAINERS does not mention who's responsible and/or willing to
> review the code you touch, and obviously you don't want to annoy some
> random people just because you think they are technically qualified
> enough or have required domain knowledge).  Sending "Hey check this out
> guys, D" emails on e.g. -hackers@ is not a good option either (as
> it would annoy even more people).

Yes, I have been looking into Herald(/MAINTAINERS integration): 
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217316 
 . I’ve put up a 
series of rules for contrib/netbsd-tests and *.test.mk, so I’ll at least be 
pinged when changes are made to these areas.
Thanks,
-Ngie


signature.asc
Description: Message signed with OpenPGP


Re: svn commit: r314189 - head/lib/libcam

2017-02-24 Thread Ngie Cooper (yaneurabeya)

> On Feb 24, 2017, at 07:36, Ian Lepore  wrote:
> 
> On Fri, 2017-02-24 at 06:24 +, Ngie Cooper wrote:
>> Author: ngie
>> Date: Fri Feb 24 06:24:39 2017
>> New Revision: 314189
>> URL: https://svnweb.freebsd.org/changeset/base/314189
>> 
>> Log:
>>   Fix up NULL/'\0' uses and fix 2 derefs after NULL
>> 
>>   MFC after: 2 weeks
>>   Reported by:   Coverity
>>   CID:   1018898, 1018899
>>   Differential Revision: https://reviews.freebsd.org/D6142
>>   Sponsored by:  Dell EMC Isilon
>> 
>> Modified:
>>   head/lib/libcam/scsi_cmdparse.c
>> 
>> Modified: head/lib/libcam/scsi_cmdparse.c
>> =
>> =
>> --- head/lib/libcam/scsi_cmdparse.c  Fri Feb 24 01:39:12 2017
>> (r314188)
>> +++ head/lib/libcam/scsi_cmdparse.c  Fri Feb 24 06:24:39 2017
>> (r314189)
>> @@ -128,14 +128,14 @@ do_buff_decode(u_int8_t *buff, size_t le
>>  *(va_arg(*ap, int *)) = (ARG); \
>>  assigned++; \
>>  } \
>> -field_name[0] = 0; \
>> +field_name[0] = '\0'; \
> 
> Is coverity seriously complaining about using 0 instead of '\0'?  What
> possible *real* benefit (not just shutting up coverity) does this churn
> bring?

Warner made the same comment.
It was actually a combination of issues brought up by Coverity and 
coccinelle (badzero.cocci). The forward-NULL CIDs noted were pointed out by 
Coverity. The NULL/‘\0’ use issues were pointed out by coccinelle.
Thanks!
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r314189 - head/lib/libcam

2017-02-24 Thread Ian Lepore
On Fri, 2017-02-24 at 13:02 -0800, Ngie Cooper (yaneurabeya) wrote:
> > 
> > On Feb 24, 2017, at 07:36, Ian Lepore  wrote:
> > 
> > On Fri, 2017-02-24 at 06:24 +, Ngie Cooper wrote:
> > > 
> > > Author: ngie
> > > Date: Fri Feb 24 06:24:39 2017
> > > New Revision: 314189
> > > URL: https://svnweb.freebsd.org/changeset/base/314189
> > > 
> > > Log:
> > >   Fix up NULL/'\0' uses and fix 2 derefs after NULL
> > > 
> > >   MFC after:  2 weeks
> > >   Reported by:Coverity
> > >   CID:1018898, 1018899
> > >   Differential Revision:  https://reviews.freebsd.org/D6142
> > >   Sponsored by:   Dell EMC Isilon
> > > 
> > > Modified:
> > >   head/lib/libcam/scsi_cmdparse.c
> > > 
> > > Modified: head/lib/libcam/scsi_cmdparse.c
> > > =
> > > 
> > > =
> > > --- head/lib/libcam/scsi_cmdparse.c   Fri Feb 24 01:39:12
> > > 2017
> > > (r314188)
> > > +++ head/lib/libcam/scsi_cmdparse.c   Fri Feb 24 06:24:39
> > > 2017
> > > (r314189)
> > > @@ -128,14 +128,14 @@ do_buff_decode(u_int8_t *buff, size_t le
> > >   *(va_arg(*ap, int *)) = (ARG); \
> > >   assigned++; \
> > >   } \
> > > - field_name[0] = 0; \
> > > + field_name[0] = '\0'; \
> > Is coverity seriously complaining about using 0 instead of
> > '\0'?  What
> > possible *real* benefit (not just shutting up coverity) does this
> > churn
> > bring?
>   Warner made the same comment.
>   It was actually a combination of issues brought up by Coverity
> and coccinelle (badzero.cocci). The forward-NULL CIDs noted were
> pointed out by Coverity. The NULL/‘\0’ use issues were pointed out by
> coccinelle.
> Thanks!
> -Ngie

Alright.  That answers everything except the actual important question.
 So, again:

What *real* benefit does this churn bring?

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

Re: svn commit: r314189 - head/lib/libcam

2017-02-24 Thread Ngie Cooper (yaneurabeya)

> On Feb 24, 2017, at 13:17, Ian Lepore  wrote:

…

> Alright.  That answers everything except the actual important question.
>  So, again:
> 
> What *real* benefit does this churn bring?

The benefits are: clarity in intent in the code and fixing dead (always false 
or always true) branches. The point you brought up is addressing the first goal.
Thanks,
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r314226 - head/usr.sbin/syslogd

2017-02-24 Thread Ngie Cooper
Author: ngie
Date: Fri Feb 24 21:35:59 2017
New Revision: 314226
URL: https://svnweb.freebsd.org/changeset/base/314226

Log:
  Use SRCTOP instead of .CURDIR relative paths with ".."
  
  This simplifies pathing in make/displayed output
  
  MFC after:1 week
  Sponsored by: Dell EMC Isilon

Modified:
  head/usr.sbin/syslogd/Makefile

Modified: head/usr.sbin/syslogd/Makefile
==
--- head/usr.sbin/syslogd/Makefile  Fri Feb 24 21:35:53 2017
(r314225)
+++ head/usr.sbin/syslogd/Makefile  Fri Feb 24 21:35:59 2017
(r314226)
@@ -3,7 +3,7 @@
 
 .include 
 
-.PATH: ${.CURDIR}/../../usr.bin/wall
+.PATH: ${SRCTOP}/usr.bin/wall
 
 PROG=  syslogd
 MAN=   syslog.conf.5 syslogd.8
@@ -20,6 +20,6 @@ CFLAGS+= -DINET
 CFLAGS+= -DINET6
 .endif
 
-CFLAGS+= -I${.CURDIR}/../../usr.bin/wall
+CFLAGS+= -I${SRCTOP}/usr.bin/wall
 
 .include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314189 - head/lib/libcam

2017-02-24 Thread Ian Lepore
On Fri, 2017-02-24 at 13:28 -0800, Ngie Cooper (yaneurabeya) wrote:
> > 
> > On Feb 24, 2017, at 13:17, Ian Lepore  wrote:
> …
> 
> > 
> > Alright.  That answers everything except the actual important
> > question.
> >  So, again:
> > 
> > What *real* benefit does this churn bring?
> The benefits are: clarity in intent in the code and fixing dead
> (always false or always true) branches. The point you brought up is
> addressing the first goal.
> Thanks,
> -Ngie

What I'masking has nothing to do with dead branches.  So, no real
benefit then.  

I'm agnostic about using bare 0 versus '\0' in a context where the type
is char.  The type of '\0' in plain-C is exactly the same as the type
of a bare 0 -- both are just integer constants.

style(9) prefers the '\0' form, but style(9) also offers these words of
wisdom:

Stylistic changes (including whitespace changes) are hard on the
source repository and are to be avoided without good reason.

I sure hope we're not going to see a big round of 'svn blame'-ruining
commits just to change 0 to '\0' throughout the repo.

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

Re: svn commit: r314216 - head/sys/x86/x86

2017-02-24 Thread Jonathan Looney
On Fri, Feb 24, 2017 at 3:19 PM, hiren panchasara <
hi...@strugglingcoder.info> wrote:

> On 02/24/17 at 06:56P, Jonathan T. Looney wrote:
> > Author: jtl
> > Date: Fri Feb 24 18:56:00 2017
> > New Revision: 314216
> > URL: https://svnweb.freebsd.org/changeset/base/314216
> >
> > Log:
> >   We have seen several cases recently where we appear to get a
> double-fault:
> >   We have an original panic. Then, instead of writing the core to the
> dump
> >   device, the kernel has a second panic: "smp_targeted_tlb_shootdown:
> >   interrupts disabled". This change is an attempt to fix that second
> panic.
> >
> >   When the other CPUs are stopped, we can't notify them of the TLB
> shootdown,
> >   so we skip that operation. However, when the CPUs come back up, we
> >   invalidate the TLB to ensure they correctly observe any changes to the
> >   page mappings.
> >
> >   Reviewed by:kib
> >   Sponsored by:   Netflix
> >   Differential Revision:  https://reviews.freebsd.org/D9786
>
> Can this be MFCd to 11?
>

It can be. I didn't propose it because I have only seen the problem on
-CURRENT. But, I see no obstacle to MFCing to stable/11, if you want to see
it there.

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


svn commit: r314231 - head/lib/libefivar

2017-02-24 Thread Warner Losh
Author: imp
Date: Sat Feb 25 00:09:21 2017
New Revision: 314231
URL: https://svnweb.freebsd.org/changeset/base/314231

Log:
  Don't convert ENOENT to nothing for individual lookup, just for the
  iterative get_next interface. This prevents efivar(3) from printing 4k
  of 0's when a variable isn't set.
  
  Sponsored by: Netflix

Modified:
  head/lib/libefivar/efivar.c

Modified: head/lib/libefivar/efivar.c
==
--- head/lib/libefivar/efivar.c Sat Feb 25 00:09:16 2017(r314230)
+++ head/lib/libefivar/efivar.c Sat Feb 25 00:09:21 2017(r314231)
@@ -132,10 +132,7 @@ rv_to_linux_rv(int rv)
 {
if (rv == 0)
rv = 1;
-   else if (errno == ENOENT) {
-   rv = 0;
-   errno = 0;
-   } else
+   else
rv = -errno;
return (rv);
 }
@@ -266,6 +263,11 @@ errout:
 
/* XXX The linux interface expects name to be a static buffer -- fix or 
leak memory? */
 done:
+   if (errno == ENOENT) {
+   errno = 0;
+   return 0;
+   }
+
return (rv_to_linux_rv(rv));
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314228 - head/sbin/nvmecontrol

2017-02-24 Thread Warner Losh
Author: imp
Date: Sat Feb 25 00:09:02 2017
New Revision: 314228
URL: https://svnweb.freebsd.org/changeset/base/314228

Log:
  Fix typos in output.
  
  Sponsored by: Netflix

Modified:
  head/sbin/nvmecontrol/logpage.c

Modified: head/sbin/nvmecontrol/logpage.c
==
--- head/sbin/nvmecontrol/logpage.c Fri Feb 24 21:38:41 2017
(r314227)
+++ head/sbin/nvmecontrol/logpage.c Sat Feb 25 00:09:02 2017
(r314228)
@@ -714,13 +714,13 @@ print_hgst_info_temp_history(void *buf, 
printf("  %-30s: %d C\n", "Minimum Temperature", *walker++);
min = le32dec(walker);
walker += 4;
-   printf("  %-30s: %d:%02d:00\n", "Max Temperture Time", min / 60, min % 
60);
+   printf("  %-30s: %d:%02d:00\n", "Max Temperature Time", min / 60, min % 
60);
min = le32dec(walker);
walker += 4;
-   printf("  %-30s: %d:%02d:00\n", "Over Temperture Duration", min / 60, 
min % 60);
+   printf("  %-30s: %d:%02d:00\n", "Over Temperature Duration", min / 60, 
min % 60);
min = le32dec(walker);
walker += 4;
-   printf("  %-30s: %d:%02d:00\n", "Min Temperture Time", min / 60, min % 
60);
+   printf("  %-30s: %d:%02d:00\n", "Min Temperature Time", min / 60, min % 
60);
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314232 - head/usr.sbin/efivar

2017-02-24 Thread Warner Losh
Author: imp
Date: Sat Feb 25 00:09:26 2017
New Revision: 314232
URL: https://svnweb.freebsd.org/changeset/base/314232

Log:
  Exit when we can't print a variable.
  
  Exit after printing a message on stderr when we can't get a
  message. This is slightly different than linux, but keeps shell
  scripts from thinking the value of the variable is the error message
  and so is a net win.
  
  Sponsored by: Netflix

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

Modified: head/usr.sbin/efivar/efivar.c
==
--- head/usr.sbin/efivar/efivar.c   Sat Feb 25 00:09:21 2017
(r314231)
+++ head/usr.sbin/efivar/efivar.c   Sat Feb 25 00:09:26 2017
(r314232)
@@ -205,21 +205,20 @@ print_var(efi_guid_t *guid, char *name)
int rv;
 
efi_guid_to_str(guid, &gname);
-   if (!Nflag)
-   printf("%s-%s", gname, name);
if (pflag) {
rv = efi_get_variable(*guid, name, &data, &datalen, &att);
 
if (rv < 0)
-   printf("\n --- Error getting value --- %d", errno);
-   else {
-   if (Aflag)
-   asciidump(data, datalen);
-   else if (bflag)
-   bindump(data, datalen);
-   else
-   hexdump(data, datalen);
-   }
+   err(1, "%s-%s", gname, name);
+
+   if (!Nflag)
+   printf("%s-%s", gname, name);
+   if (Aflag)
+   asciidump(data, datalen);
+   else if (bflag)
+   bindump(data, datalen);
+   else
+   hexdump(data, datalen);
}
free(gname);
if (!Nflag)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314229 - head/sbin/nvmecontrol

2017-02-24 Thread Warner Losh
Author: imp
Date: Sat Feb 25 00:09:12 2017
New Revision: 314229
URL: https://svnweb.freebsd.org/changeset/base/314229

Log:
  Exit with usage if argv[1] is NULL in dispatch. This fixes core dumps
  when a command has subcommands, but the user doesn't give the
  parameters on the command line.
  
  Sponsored by: Netflix

Modified:
  head/sbin/nvmecontrol/nvmecontrol.c

Modified: head/sbin/nvmecontrol/nvmecontrol.c
==
--- head/sbin/nvmecontrol/nvmecontrol.c Sat Feb 25 00:09:02 2017
(r314228)
+++ head/sbin/nvmecontrol/nvmecontrol.c Sat Feb 25 00:09:12 2017
(r314229)
@@ -75,6 +75,11 @@ dispatch(int argc, char *argv[], struct 
 {
struct nvme_function *f = tbl;
 
+   if (argv[1] == NULL) {
+   gen_usage(tbl);
+   return;
+   }
+
while (f->name != NULL) {
if (strcmp(argv[1], f->name) == 0)
f->fn(argc-1, &argv[1]);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314230 - head/sbin/nvmecontrol

2017-02-24 Thread Warner Losh
Author: imp
Date: Sat Feb 25 00:09:16 2017
New Revision: 314230
URL: https://svnweb.freebsd.org/changeset/base/314230

Log:
  Make nvmecontrol logpage -p help list known pages.
  
  Make -p help and -v help list all the pages we know about.
  Add -v to usage.
  Update the man page.
  
  Sponsored by: Netflix

Modified:
  head/sbin/nvmecontrol/logpage.c
  head/sbin/nvmecontrol/nvmecontrol.8
  head/sbin/nvmecontrol/nvmecontrol.h

Modified: head/sbin/nvmecontrol/logpage.c
==
--- head/sbin/nvmecontrol/logpage.c Sat Feb 25 00:09:12 2017
(r314229)
+++ head/sbin/nvmecontrol/logpage.c Sat Feb 25 00:09:16 2017
(r314230)
@@ -369,7 +369,7 @@ print_intel_write_lat_log(void *buf, uin
 }
 
 /*
- * Table 19. 5.4 SMART Attributes
+ * Table 19. 5.4 SMART Attributes. Samsung also implements this and some extra 
data not documented.
  */
 static void
 print_intel_add_smart(void *buf, uint32_t size __unused)
@@ -835,34 +835,39 @@ print_hgst_info_log(void *buf, uint32_t 
 /*
  * Table of log page printer / sizing.
  *
- * This includes Intel specific pages that are widely implemented. Not
- * sure how best to switch between different vendors.
+ * This includes Intel specific pages that are widely implemented.
+ * Make sure you keep all the pages of one vendor together so -v help
+ * lists all the vendors pages.
  */
 static struct logpage_function {
uint8_t log_page;
const char *vendor;
+   const char *name;
print_fn_t  print_fn;
size_t  size;
 } logfuncs[] = {
-   {NVME_LOG_ERROR,NULL,   print_log_error,
-0},
-   {NVME_LOG_HEALTH_INFORMATION,   NULL,   print_log_health,
-sizeof(struct nvme_health_information_page)},
-   {NVME_LOG_FIRMWARE_SLOT,NULL,   print_log_firmware,
-sizeof(struct nvme_firmware_page)},
-   {HGST_INFO_LOG, "hgst", print_hgst_info_log,
-DEFAULT_SIZE},
-   {HGST_INFO_LOG, "wdc",  print_hgst_info_log,
-DEFAULT_SIZE},
-   {INTEL_LOG_TEMP_STATS,  "intel", print_intel_temp_stats,
-sizeof(struct intel_log_temp_stats)},
-   {INTEL_LOG_READ_LAT_LOG,"intel", print_intel_read_lat_log,
-DEFAULT_SIZE},
-   {INTEL_LOG_WRITE_LAT_LOG,   "intel", print_intel_write_lat_log,
-DEFAULT_SIZE},
-   {INTEL_LOG_ADD_SMART,   "intel", print_intel_add_smart,
-DEFAULT_SIZE},
-   {0, NULL,   NULL,0},
+   {NVME_LOG_ERROR,NULL,   "Drive Error Log",
+print_log_error,   0},
+   {NVME_LOG_HEALTH_INFORMATION,   NULL,   "Health/SMART Data",
+print_log_health,  sizeof(struct 
nvme_health_information_page)},
+   {NVME_LOG_FIRMWARE_SLOT,NULL,   "Firmware Information",
+print_log_firmware,sizeof(struct nvme_firmware_page)},
+   {HGST_INFO_LOG, "hgst", "Detailed Health/SMART",
+print_hgst_info_log,   DEFAULT_SIZE},
+   {HGST_INFO_LOG, "wds",  "Detailed Health/SMART",
+print_hgst_info_log,   DEFAULT_SIZE},
+   {INTEL_LOG_TEMP_STATS,  "intel", "Temperature Stats",
+print_intel_temp_stats,sizeof(struct intel_log_temp_stats)},
+   {INTEL_LOG_READ_LAT_LOG,"intel", "Read Latencies",
+print_intel_read_lat_log,  DEFAULT_SIZE},
+   {INTEL_LOG_WRITE_LAT_LOG,   "intel", "Write Latencies",
+print_intel_write_lat_log, DEFAULT_SIZE},
+   {INTEL_LOG_ADD_SMART,   "intel", "Extra Health/SMART Data",
+print_intel_add_smart, DEFAULT_SIZE},
+   {INTEL_LOG_ADD_SMART,   "samsung", "Extra Health/SMART Data",
+print_intel_add_smart, DEFAULT_SIZE},
+
+   {0, NULL, NULL, NULL, 0},
 };
 
 static void
@@ -873,6 +878,23 @@ logpage_usage(void)
exit(1);
 }
 
+static void
+logpage_help(void)
+{
+   struct logpage_function *f;
+   const char  *v;
+
+   fprintf(stderr, "\n");
+   fprintf(stderr, "%-8s %-10s %s\n", "Page", "Vendor","Page Name");
+   fprintf(stderr, " -- --\n");
+   for (f = logfuncs; f->log_page > 0; f++) {
+   v = f->vendor == NULL ? "-" : f->vendor;
+   fprintf(stderr, "0x%02x %-10s %s\n", f->log_page, v, 
f->name);
+   }
+
+   exit(1);
+}
+
 void
 logpage(int argc, char *argv[])
 {
@@ -894,6 +916,9 @@ logpage(int argc, char *argv[])
binflag = true;
break;
case 'p':
+   if (strcmp(optarg, "help") == 0)
+   logpage_help();
+
/* TODO: Add human-readable ASCII page IDs */
log_page = strtol(optarg, &p, 0);
  

svn commit: r314233 - head/usr.sbin/syslogd

2017-02-24 Thread Ngie Cooper
Author: ngie
Date: Sat Feb 25 00:12:29 2017
New Revision: 314233
URL: https://svnweb.freebsd.org/changeset/base/314233

Log:
  Parameterize out the length of struct filed->f_lasttime as `MAXDATELEN`
  
  This removes the hardcoded value for the field (16) and the equivalent
  hardcoded lengths in logmsg(..).
  
  This change is being done to help stage future work to add RFC5424/RFC5434
  support to syslogd(8).
  
  Obtained from:Isilon OneFS (dcd33d13da) (as part of a larger change)
  Submitted by: John Bauman 
  MFC after:2 weeks
  Sponsored by: Dell EMC Isilon

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

Modified: head/usr.sbin/syslogd/syslogd.c
==
--- head/usr.sbin/syslogd/syslogd.c Sat Feb 25 00:09:26 2017
(r314232)
+++ head/usr.sbin/syslogd/syslogd.c Sat Feb 25 00:12:29 2017
(r314233)
@@ -68,6 +68,8 @@ __FBSDID("$FreeBSD$");
  * Priority comparison code by Harlan Stenn.
  */
 
+/* Maximum number of characters in time of last occurrence */
+#defineMAXDATELEN  16
 #defineMAXLINE 1024/* maximum line length */
 #defineMAXSVLINE   MAXLINE /* maximum saved line length */
 #defineDEFUPRI (LOG_USER|LOG_NOTICE)
@@ -212,7 +214,7 @@ struct filed {
 #definefu_pipe_pname   f_un.f_pipe.f_pname
 #definefu_pipe_pid f_un.f_pipe.f_pid
charf_prevline[MAXSVLINE];  /* last message logged */
-   charf_lasttime[16]; /* time of last occurrence */
+   charf_lasttime[MAXDATELEN]; /* time of last occurrence */
charf_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */
int f_prevpri;  /* pri of f_prevline */
int f_prevlen;  /* length of f_prevline */
@@ -1034,7 +1036,7 @@ logmsg(int pri, const char *msg, const c
 * Check to see if msg looks non-standard.
 */
msglen = strlen(msg);
-   if (msglen < 16 || msg[3] != ' ' || msg[6] != ' ' ||
+   if (msglen < MAXDATELEN || msg[3] != ' ' || msg[6] != ' ' ||
msg[9] != ':' || msg[12] != ':' || msg[15] != ' ')
flags |= ADDDATE;
 
@@ -1043,8 +1045,8 @@ logmsg(int pri, const char *msg, const c
timestamp = ctime(&now) + 4;
} else {
timestamp = msg;
-   msg += 16;
-   msglen -= 16;
+   msg += MAXDATELEN;
+   msglen -= MAXDATELEN;
}
 
/* skip leading blanks */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r313268 - head/sys/kern [through -r313271 for atomic_fcmpset use and later: fails on PowerMac G5 "Quad Core"; -r313266 works]

2017-02-24 Thread Mateusz Guzik
On Tue, Feb 21, 2017 at 01:37:25AM -0800, Mark Millard wrote:
> [Back to the powerpc64 context.]
> 
> On 2017-Feb-20, at 11:10 AM, Mateusz Guzik  wrote:
> 
> > On Sat, Feb 18, 2017 at 04:18:05AM -0800, Mark Millard wrote:
> >> [Note: I experiment with clang based powerpc64 builds,
> >> reporting problems that I find. Justin is familiar
> >> with this, as is Nathan.]
> >> 
> >> I tried to update the PowerMac G5 (a so-called "Quad Core")
> >> that I have access to from head -r312761 to -r313864 and
> >> ended up with random panics and hang ups in fairly short
> >> order after booting.
> >> 
> >> Some approximate bisecting for the kernel lead to:
> >> (sometimes getting part way into a buildkernel attempt
> >> for a different version before a failure happens)
> >> 
> >> -r313266: works (just before use of atomic_fcmpset)
> >> vs.
> >> -r313271: fails (last of the "use atomic_fcmpset" check-ins)
> >> 
> >> (I did not try -r313268 through -r313270 as the use was
> >> gradually added.)
> >> 
> >> So I'm currently running a -r313864 world with a -r313266
> >> kernel.
> >> 
> >> No kernel that I tried that was from before -r313266 had the
> >> problems.
> >> 
> >> Any kernel that I tried that was from after -r313271 had the
> >> problems.
> >> 
> >> Of course I did not try them all in other direction. :)
> >> 
> > 
> > I found that spin mutexes were not properly handling this, fixed in
> > r313996.
> > 
> > Locally I added a if (cpu_tick() % 2) return (0); snipped to amd64
> > fcmpset to simulate failures. Everything works, while it would easily
> > fail without the patch.
> > 
> > That said, I hope this concludes the 'missing check for not-reread value
> > of failed fcmpset' saga.
> > 
> > -- 
> > Mateusz Guzik 
> 
> -r313999 is an improvement for powerpc64: it boots and I can
> log in on the old PowerMac G5 so-called "Quad Core".
> 
> But, e.g., buildworld buildkernel eventually hangs and later
> the powerpc64 panics for "spin lock held too long".
> 

Allright, play time is over.

Can you please:
1. verify r313254 is stable for you
2. apply https://people.freebsd.org/~mjg/patches/complete-locks.diff and
https://people.freebsd.org/~mjg/.junk/ppc.diff on top of it and retry
the test?

This is a workaround which effectively disables the powerpc-specific
primitive and makes it use a cmpset wrapper instead. I don't have the
hardware to test right now and my attempts to boot in qemu also failed.

That said, does not look like there are general fcmpset bugs left and
the remaining issue seems powerpc-specific.

If this works, I'll commit the workaround for the time being as in few
weeks I'd like to start merging the work back to stable/11.

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


svn commit: r314234 - head/sys/dev/iwn

2017-02-24 Thread Andriy Voskoboinyk
Author: avos
Date: Sat Feb 25 00:40:50 2017
New Revision: 314234
URL: https://svnweb.freebsd.org/changeset/base/314234

Log:
  iwn: some initialization / RF switch state change fixes.
  
  - Check return code from initialization path; otherwise, vap state
  may be wrong after an error.
  - Do not try to run iwn_stop() / iwn_init() multiple times.
  - Merge iwn_radio_on/off() and move RFKILL bit check into the task.
  - Try to handle possible RF switch state change in S3 state (PR 181694).
  
  PR:   181694
  Reviewed by:  adrian
  Differential Revision:https://reviews.freebsd.org/D9797

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==
--- head/sys/dev/iwn/if_iwn.c   Sat Feb 25 00:12:29 2017(r314233)
+++ head/sys/dev/iwn/if_iwn.c   Sat Feb 25 00:40:50 2017(r314234)
@@ -217,7 +217,7 @@ static void iwn_ampdu_tx_done(struct iwn
 static voidiwn_cmd_done(struct iwn_softc *, struct iwn_rx_desc *);
 static voidiwn_notif_intr(struct iwn_softc *);
 static voidiwn_wakeup_intr(struct iwn_softc *);
-static voidiwn_rftoggle_intr(struct iwn_softc *);
+static voidiwn_rftoggle_task(void *, int);
 static voidiwn_fatal_intr(struct iwn_softc *);
 static voidiwn_intr(void *);
 static voidiwn4965_update_sched(struct iwn_softc *, int, int, uint8_t,
@@ -334,11 +334,9 @@ static int iwn5000_nic_config(struct iwn
 static int iwn_hw_prepare(struct iwn_softc *);
 static int iwn_hw_init(struct iwn_softc *);
 static voidiwn_hw_stop(struct iwn_softc *);
-static voidiwn_radio_on(void *, int);
-static voidiwn_radio_off(void *, int);
 static voidiwn_panicked(void *, int);
-static voidiwn_init_locked(struct iwn_softc *);
-static voidiwn_init(struct iwn_softc *);
+static int iwn_init_locked(struct iwn_softc *);
+static int iwn_init(struct iwn_softc *);
 static voidiwn_stop_locked(struct iwn_softc *);
 static voidiwn_stop(struct iwn_softc *);
 static voidiwn_scan_start(struct ieee80211com *);
@@ -679,8 +677,7 @@ iwn_attach(device_t dev)
callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0);
callout_init_mtx(&sc->scan_timeout, &sc->sc_mtx, 0);
callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0);
-   TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc);
-   TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc);
+   TASK_INIT(&sc->sc_rftoggle_task, 0, iwn_rftoggle_task, sc);
TASK_INIT(&sc->sc_panic_task, 0, iwn_panicked, sc);
TASK_INIT(&sc->sc_xmit_task, 0, iwn_xmit_task, sc);
 
@@ -1401,8 +1398,6 @@ iwn_detach(device_t dev)
iwn_xmit_queue_drain(sc);
IWN_UNLOCK(sc);
 
-   ieee80211_draintask(&sc->sc_ic, &sc->sc_radioon_task);
-   ieee80211_draintask(&sc->sc_ic, &sc->sc_radiooff_task);
iwn_stop(sc);
 
taskqueue_drain_all(sc->sc_tq);
@@ -4013,19 +4008,28 @@ iwn_wakeup_intr(struct iwn_softc *sc)
 }
 
 static void
-iwn_rftoggle_intr(struct iwn_softc *sc)
+iwn_rftoggle_task(void *arg, int npending)
 {
+   struct iwn_softc *sc = arg;
struct ieee80211com *ic = &sc->sc_ic;
-   uint32_t tmp = IWN_READ(sc, IWN_GP_CNTRL);
+   uint32_t tmp;
 
-   IWN_LOCK_ASSERT(sc);
+   IWN_LOCK(sc);
+   tmp = IWN_READ(sc, IWN_GP_CNTRL);
+   IWN_UNLOCK(sc);
 
device_printf(sc->sc_dev, "RF switch: radio %s\n",
(tmp & IWN_GP_CNTRL_RFKILL) ? "enabled" : "disabled");
-   if (tmp & IWN_GP_CNTRL_RFKILL)
-   ieee80211_runtask(ic, &sc->sc_radioon_task);
-   else
-   ieee80211_runtask(ic, &sc->sc_radiooff_task);
+   if (!(tmp & IWN_GP_CNTRL_RFKILL)) {
+   ieee80211_suspend_all(ic);
+
+   /* Enable interrupts to get RF toggle notification. */
+   IWN_LOCK(sc);
+   IWN_WRITE(sc, IWN_INT, 0x);
+   IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask);
+   IWN_UNLOCK(sc);
+   } else
+   ieee80211_resume_all(ic);
 }
 
 /*
@@ -4139,7 +4143,7 @@ iwn_intr(void *arg)
IWN_WRITE(sc, IWN_FH_INT, r2);
 
if (r1 & IWN_INT_RF_TOGGLED) {
-   iwn_rftoggle_intr(sc);
+   taskqueue_enqueue(sc->sc_tq, &sc->sc_rftoggle_task);
goto done;
}
if (r1 & IWN_INT_CT_REACHED) {
@@ -5084,25 +5088,28 @@ static void
 iwn_parent(struct ieee80211com *ic)
 {
struct iwn_softc *sc = ic->ic_softc;
-   struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-   int startall = 0, stop = 0;
- 
-   IWN_LOCK(sc);
+   struct ieee80211vap *vap;
+   int error;
+
if (ic->ic_nrunning > 0) {
-   if (!(sc->sc_flags & IWN_FLAG_RUNNING)) {
-   iwn_init_locked(sc);
-   if (IWN_READ(sc, IWN_GP_CNTRL) & IWN_GP_CNTRL_RFKILL)
-

Re: svn commit: r314179 - in head: contrib/netbsd-tests/lib/librt include lib/libc/gen lib/libc/include share/man/man3 sys/kern

2017-02-24 Thread Bruce Evans

On Fri, 24 Feb 2017, Konstantin Belousov wrote:


On Thu, Feb 23, 2017 at 07:36:39PM +, Eric van Gyzen wrote:

Modified: head/include/semaphore.h
==
--- head/include/semaphore.hThu Feb 23 19:32:25 2017(r314178)
+++ head/include/semaphore.hThu Feb 23 19:36:38 2017(r314179)
@@ -59,6 +59,8 @@ intsem_init(sem_t *, int, unsigned int
 sem_t  *sem_open(const char *, int, ...);
 int sem_post(sem_t *);
 int sem_timedwait(sem_t * __restrict, const struct timespec * __restrict);
+int sem_clockwait_np(sem_t * __restrict, __clockid_t, int,
+   const struct timespec *, struct timespec *);

I argue that semaphore.h is POSIX include file and the declaration of
sem_clockwait_np(), despite being in implementation (non-portable)
namespace, still should be braced with #if __BSD_VISIBLE.


This declaration also unsorts the list.  Similarly in the man page, except
at least 4 shorter lists are unsorted and sorting them would hide the
primary API.

This declaration has rather too much pollution avoidance.  It is almost
unusable without including another header that declares clockid_t, and
of course the man page gives not even a hint about this.

The implementation and POSIX has or had the same bug for sem_timewait().
That uses struct timespec, but in the 2001 version  wasn't
required to declare struct timespec.  The 2007 draft version is even
worse.  It still doesn't require  to declare struct
timespec, but allows  to be polluted with all the symbols
in .  I haven't checked later versions.  POSIX generally
"fixes" such bugs by requiring declarations of all relevant types but
allowing low quality implemenations to do this by including massive
pollution.  At least it documents the pollution.

I don't like multiple functions per man page.   mostly
has separate ones.  It has 11 functions and at least 8 separate man
pages.  Details like extra headers being needed are easier to organize
in separate man pages (but both clockid_t and struct timespec need
the same man page ).


 int sem_trywait(sem_t *);
 int sem_unlink(const char *);
 int sem_wait(sem_t *);


FreeBSD is still missing clock_nanosleep(), and has a broken nanosleep()
that sleeps on a wrong clock id.  I would have thought that this standard
function was needed more than a nonstandard semaphore function.  Eric
even mentioned clock_nanosleep() in the commit log.

Interestingly, sem_timedwait() is not broken like nanosleep().  POSIX
specifies that both sleep on CLOCK_REALTIME.  It isn't clear what this
means if someone steps the clock to adjust it, but it clearly requires
jumping by a second or 2 for leap seconds, and the implementation doesn't
do that very well (it should wake up a second or 2 early in case there is
a leap second, or for long sleeps a few percent early in case there is
clock drift, then micro-sleep to the final time).

kern_sem_wait() uses an old-style wait loop with the right clock id
but a low precision (getnanotime() uses CLOCK_REALTIME_FAST, not
CLOCK_REALTIME, so its id is not quite right either).

nanosleep() originally used the wrong clock id CLOCK_MONOTONIC_FAST
via getnanotime() in an old-style wait loop.  Now it uses sbintimes
via tsleep_sbt().  Sbintime APIs only support monotonic clocks, so
changing to the correct clock is not so easy.

POSIX timers seem to be little used, and the POSIX timer code that
supports clock ids and absolute times hasn't been converted to use
sbintimes.  It uses kernel timeouts, which are fundamentally based
on monotonic clocks, and isn't careful to wake up early to handle
leap seconds or drift.

The benefit from using sbintimes for nanosleep() seems to be just that
you can avoid reqesting a high precision, and with a little more
precision control you could reqest an early wakeup.  IIRC, the current
precision control is biased towards waking up late, and in a keyboard
function I had to fudge it to wake up early or late with no bias, but
in nanosleep() early wakeups would be preferred and for long timeouts
and timeouts across clock steps early wakeups should be mandatory.

This shows a good way to handle all clock steps: wake up immediately
to let the wait loop check the time and usually restart.  Only higher
levels can know the correct handling.  They should already be prepared
for early wakeups because these are caused by interrupts.

kern_sem_wait() does check after an interrupt, but not after a timeout
(it assumes that timeouts in hz ticks with the monotonic hz clock are
accurate for the CLOCK_REALTIME[_FAST] timecounter clock).
kern_nanosleep() used to check after a timeout, but it now depends on
timeouts in sbintimes with the monotonic sbintime clock being
accurate...  The sbintime clock is essentially CLOCK_MONOTONIC_[FAST],
so it is accurate enough, but with a wrong clock id.

Bruce
___
svn-src-head@freebsd.org mailing list
https://li

svn commit: r314239 - head/rescue/rescue

2017-02-24 Thread Ngie Cooper
Author: ngie
Date: Sat Feb 25 03:11:08 2017
New Revision: 314239
URL: https://svnweb.freebsd.org/changeset/base/314239

Log:
  Add shutdown/poweroff support to rescue(8)
  
  shutdown is a safer way to power off than reboot (in general), because of
  the added shutdown process that it executes via /etc/rc.shutdown . It was
  odd that it was missing from rescue(8) since reboot and friends were
  added in past commits.
  
  While here, alias poweroff to shutdown for parity with sbin/shutdown/Makefile
  
  MFC after:2 weeks
  Sponsored by: Dell EMC Isilon

Modified:
  head/rescue/rescue/Makefile

Modified: head/rescue/rescue/Makefile
==
--- head/rescue/rescue/Makefile Sat Feb 25 01:53:45 2017(r314238)
+++ head/rescue/rescue/Makefile Sat Feb 25 03:11:08 2017(r314239)
@@ -99,7 +99,7 @@ CRUNCH_PROGS_sbin= badsect
\
mount_udf mount_unionfs newfs   \
newfs_msdos nos-tun ping reboot \
restore rcorder route routed rtquery rtsol savecore \
-   spppcontrol swapon sysctl tunefs umount
+   shutdown spppcontrol swapon sysctl tunefs umount
 
 .if ${MK_ATM} != "no"
 CRUNCH_PROGS_sbin+= atmconfig
@@ -166,6 +166,7 @@ CRUNCH_ALIAS_restore= rrestore
 CRUNCH_ALIAS_dump= rdump
 CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
 CRUNCH_ALIAS_geom= glabel gpart
+CRUNCH_ALIAS_shutdown= poweroff
 
 # dhclient has historically been troublesome...
 CRUNCH_PROGS_sbin+= dhclient
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314087 - head/sys/x86/x86

2017-02-24 Thread Bruce Evans

On Fri, 24 Feb 2017, Konstantin Belousov wrote:


On Thu, Feb 23, 2017 at 06:33:43AM +1100, Bruce Evans wrote:

On Wed, 22 Feb 2017, Konstantin Belousov wrote:


Log:
 More fixes for regression in r313898 on i386.
 Use long long constants where needed.


The long long abomination is never needed, and is always a style bug.

I never saw any explanation behind this claim.  Esp. the first part
of it, WRT 'never needed'.


I hope I wrote enough about this in log messages when I cleaned up the
long longs 20 years ago :-).

long long was a hack to work around intmax_t not existing and long being
unexpandable in practice because it was used in ABIs.  It should have gone
away when intmax_t was standardized.  Unfortunately, long long was
standardised too.

It is "never needed" since anything that can be done with it can be done
better using intmax_t or intN_t or int_fastN_T or int_leastN_t.  Except,
there is no suffix for explicit intmax_t constants, so you would have to
write such constants using INTMAX_C() or better a cast to intmax_t if
the constant is not needed in a cpp expression.


I don't like using explicit long constants either.  Here the number of bits
in the register is fixed by the hardware at 64.  The number of bits in a
long on amd64 and a long on i386 is only fixed by ABI because the ABI is
broken for historical reasons.

I really cannot make any sense of this statement.


To know that the ULL suffix is correct for 64-bit types, you have to now
that long longs are 64 bits on all arches supported by the code.  Then
to use this suffix, you have to hard-code this knowledge.  Then to read
the code, the reader has to translate back to 64 bits.  The translations
were easier 1 arch at a time.  Casting to uint64_t is clearer, but doesn't
work in cpp expressions.  In cpp expressions, use UINT64_C().  Almost no
one knows about it uses this.  There are 5 examples of using it in /sys
(3 in arm64 pte.h, 1 in powerpc pte.h, and 1 in mips xlr_machdep.c,
where the use is unnecessary but interesting: it is ~UINT64_C(0).  We
used to have squillions of magic ~0's for the rman max limit.  This was
spelled ~0U, ~0UL and perhaps even plain ~0.  Plain ~0 worked best except
on unsupported 1's complement machines, since it normally gets sign extended
to as many bits as necessary.  Now this is spelled RM_MAX_END, which is
implemented non-magically using a cast: (~(rman_res_t)0).  Grepping for
~0[uU] in dev/* shows only 1 obvious unconverted place.


 Only very MD code can safely assume the
size of long and long long.  This code was MD enough before it was merged,
but now it shouldn't use long since that varies between amd64 and i386,
and it shouldn't use long long since that is a style bug.


Well, I do not see anything wrong with long long, at least until
explained.

Anyway, below is the patch to use uint64_t cast in important place,
and removal of LL suffix in unimportant expression.


This is correct.


diff --git a/sys/x86/x86/x86_mem.c b/sys/x86/x86/x86_mem.c
index d639224f840..8bc4d3917a0 100644
--- a/sys/x86/x86/x86_mem.c
+++ b/sys/x86/x86/x86_mem.c
@@ -260,7 +260,7 @@ x86_mrfetch(struct mem_range_softc *sc)

/* Compute the range from the mask. Ick. */
mrd->mr_len = (~(msrv & mtrr_physmask) &
-   (mtrr_physmask | 0xfffLL)) + 1;
+   (mtrr_physmask | 0xfff)) + 1;
if (!mrvalid(mrd->mr_base, mrd->mr_len))
mrd->mr_flags |= MDF_BOGUS;

@@ -638,7 +638,8 @@ x86_mrinit(struct mem_range_softc *sc)
 * Determine the size of the PhysMask and PhysBase fields in
 * the variable range MTRRs.
 */
-   mtrr_physmask = (((uint64_t)1 << cpu_maxphyaddr) - 1) & ~0xfffULL;
+   mtrr_physmask = (((uint64_t)1 << cpu_maxphyaddr) - 1) &
+   ~(uint64_t)0xfff;

/* If fixed MTRRs supported and enabled. */
if ((mtrrcap & MTRR_CAP_FIXED) && (mtrrdef & MTRR_DEF_FIXED_ENABLE)) {


Now I wonder what these magic 0xfff's are.  Are they PAGE_MASK, where the
register is encoded like a page table to put metadata in the low bits?

There is already a macro MTRR_PHYSBASE_PHYSMASK which looks like it should
be used here, except it is zero in the top 12 bits too.

There is no macro for 0xfff, but you get that by ORing the bits for other
macros.  0xfff is just as readable.

The MTRR_* macros are in x86/specialreg.h, and are spelled without ULL
suffixes.  I prefer the latter, but seem to rememeber bugs elsewhere
caused by using expressions like ~FOO where FOO happens to be small.
Actually the problems are mostly when FOO happens to be between
INT_MAX+1U and UINT_MAX.  When FOO is small and has no suffix, e.g.,
if it is 0, then its type is int and ~FOO has type int and sign-extends
to 64 bits if necessary.  But if FOO is say 0x8000, it has type u_int
so ~FOO doesn't sign-extend.  (Decimal constants without a suffix never
have an unsigned type and the hex constant here lets me write this number
and automat

Re: svn commit: r314192 - in head/sys: conf dev/iwm modules/iwm

2017-02-24 Thread Cy Schubert
Cool! Thanks.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


In message 
, Adrian Chadd writes:
> Fixed!
> 
> 
> -a
> 
> 
> On 24 February 2017 at 06:10, Cy Schubert  wrote:
> > In message <201702240707.v1o77was011...@repo.freebsd.org>, Adrian Chadd
> > writes:
> >> Author: adrian
> >> Date: Fri Feb 24 07:07:58 2017
> >> New Revision: 314192
> >> URL: https://svnweb.freebsd.org/changeset/base/314192
> >>
> >> Log:
> >>   [iwm] Add support for Firmware paging, needed for newer 8000C firmware.
> >>
> >>   * Uses the IWM_FW_PAGING_BLOCK_CMD firmware command to tell the firmware
> >> what memory ranges to use for paging.
> >>
> >>   Obtained from:  dragonflybsd.git 8a5b199964f8e7bdb00039f0b48817a01b4
> 02f
> >> 18
> >>
> >> Modified:
> >>   head/sys/conf/files
> >>   head/sys/dev/iwm/if_iwm.c
> >>   head/sys/dev/iwm/if_iwm_debug.h
> >>   head/sys/dev/iwm/if_iwmreg.h
> >>   head/sys/dev/iwm/if_iwmvar.h
> >>   head/sys/modules/iwm/Makefile
> >
> > Looks like you forgot svn add.
> >
> > --- all_subdir_iwm ---
> > make[4]: make[4]: don't know how to make if_iwm_fw.c. Stop
> >
> > make[4]: stopped in /opt/src/svn-current/sys/modules/iwm
> > *** [all_subdir_iwm] Error code 2
> >
> > make[3]: stopped in /opt/src/svn-current/sys/modules
> >
> >
> > --
> > Cheers,
> > Cy Schubert 
> > FreeBSD UNIX: Web:  http://www.FreeBSD.org
> >
> > The need of the many outweighs the greed of the few.
> >
> >
> 


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


Re: svn commit: r314209 - head/sys/dev/iwm

2017-02-24 Thread Cy Schubert
In message 
, Adrian Chadd writes:
> [snip]
> 
> (adrian ran out of coffee at home three days ago.)

I make sure I have lots of the stuff here. I can't survive without my 
4-shot Americanos.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


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


svn commit: r314240 - in head: rescue/rescue tools/build/mk

2017-02-24 Thread Ngie Cooper
Author: ngie
Date: Sat Feb 25 03:23:11 2017
New Revision: 314240
URL: https://svnweb.freebsd.org/changeset/base/314240

Log:
  Conditionally compile certain programs into rescue(8) if requested
  
  MK_CCD - ccdconfig
  MK_ROUTED - routed, rtquery
  
  MFC after:2 weeks
  Sponsored by: Dell EMC Isilon

Modified:
  head/rescue/rescue/Makefile
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/rescue/rescue/Makefile
==
--- head/rescue/rescue/Makefile Sat Feb 25 03:11:08 2017(r314239)
+++ head/rescue/rescue/Makefile Sat Feb 25 03:23:11 2017(r314240)
@@ -90,7 +90,7 @@ CRUNCH_SUPPRESS_LINK_-tcsh= 1
 #
 CRUNCH_SRCDIRS+= sbin
 CRUNCH_PROGS_sbin= badsect \
-   camcontrol ccdconfig clri devfs dmesg dump  \
+   camcontrol clri devfs dmesg dump\
dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb   \
fsirand gbde geom ifconfig init \
kldconfig kldload kldstat kldunload ldconfig\
@@ -98,13 +98,17 @@ CRUNCH_PROGS_sbin= badsect  
\
mount_msdosfs mount_nfs mount_nullfs\
mount_udf mount_unionfs newfs   \
newfs_msdos nos-tun ping reboot \
-   restore rcorder route routed rtquery rtsol savecore \
+   restore rcorder route rtsol savecore\
shutdown spppcontrol swapon sysctl tunefs umount
 
 .if ${MK_ATM} != "no"
 CRUNCH_PROGS_sbin+= atmconfig
 .endif
 
+.if ${MK_CCD} != "no"
+CRUNCH_PROGS_sbin+= ccdconfig
+.endif
+
 .if ${MK_INET6_SUPPORT} != "no"
 CRUNCH_PROGS_sbin+= ping6
 .endif
@@ -112,6 +116,11 @@ CRUNCH_PROGS_sbin+= ping6
 .if ${MK_IPFILTER} != "no"
 CRUNCH_PROGS_sbin+= ipf
 .endif
+
+.if ${MK_ROUTED} != "no"
+CRUNCH_PROGS_sbin+= routed rtquery
+.endif
+
 .if ${MK_ZFS} != "no"
 CRUNCH_PROGS_sbin+= zfs
 CRUNCH_PROGS_sbin+= zpool

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:11:08 
2017(r314239)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:23:11 
2017(r314240)
@@ -1197,6 +1197,7 @@ OLD_FILES+=usr/share/man/man8/casperd.8.
 
 .if ${MK_CCD} == no
 OLD_FILES+=etc/rc.d/ccd
+OLD_FILES+=rescue/ccdconfig
 OLD_FILES+=sbin/ccdconfig
 OLD_FILES+=usr/share/man/man4/ccd.4.gz
 OLD_FILES+=usr/share/man/man8/ccdconfig.8.gz
@@ -7466,6 +7467,8 @@ OLD_FILES+=usr/share/man/man8/rwhod.8.gz
 #.endif
 
 .if ${MK_ROUTED} == no
+OLD_FILES+=rescue/routed
+OLD_FILES+=rescue/rtquery
 OLD_FILES+=sbin/routed
 OLD_FILES+=sbin/rtquery
 OLD_FILES+=usr/share/man/man8/routed.8.gz
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314241 - head/tools/build/mk

2017-02-24 Thread Ngie Cooper
Author: ngie
Date: Sat Feb 25 03:28:49 2017
New Revision: 314241
URL: https://svnweb.freebsd.org/changeset/base/314241

Log:
  Fill in MK_RESCUE by finding paths in ${DESTDIR}/rescue and adding
  them to OLD_FILES/OLD_DIRS, as necessary.
  
  MFC after:1 month
  Sponsored by: Dell EMC Isilon

Modified:
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:23:11 
2017(r314240)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:28:49 
2017(r314241)
@@ -7462,9 +7462,14 @@ OLD_FILES+=usr/share/man/man8/rshd.8.gz
 OLD_FILES+=usr/share/man/man8/rwhod.8.gz
 .endif
 
-#.if ${MK_RESCUE} == no
-# to be filled in or replaced with a special target
-#.endif
+.if ${MK_RESCUE} == no
+. if exists(${DESTDIR}${TESTSBASE})
+RESCUE_DIRS!=find ${DESTDIR}/rescue -type d | sed -e 's,^${DESTDIR}/,,'; echo
+OLD_DIRS+=${RESCUE_DIRS}
+RESCUE_FILES!=find ${DESTDIR}/rescue \! -type d | sed -e 's,^${DESTDIR}/,,'; 
echo
+OLD_FILES+=${RESCUE_FILES}
+. endif
+.endif
 
 .if ${MK_ROUTED} == no
 OLD_FILES+=rescue/routed
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314242 - head/tools/build/mk

2017-02-24 Thread Ngie Cooper
Author: ngie
Date: Sat Feb 25 03:33:09 2017
New Revision: 314242
URL: https://svnweb.freebsd.org/changeset/base/314242

Log:
  Remove MK_CRYPT stub
  
  It doesn't directly control what gets installed today; it indirectly
  pulls other knobs (like MK_KERBEROS, etc).
  
  MFC after:1 weeks
  Sponsored by: Dell EMC Isilon

Modified:
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:28:49 
2017(r314241)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:33:09 
2017(r314242)
@@ -1515,10 +1515,6 @@ OLD_FILES+=usr/bin/cpp
 OLD_FILES+=usr/share/man/man1/cpp.1.gz
 .endif
 
-#.if ${MK_CRYPT} == no
-# to be filled in
-#.endif
-
 .if ${MK_CTM} == no
 OLD_FILES+=usr/sbin/ctm
 OLD_FILES+=usr/sbin/ctm_dequeue
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314244 - head/tools/build/mk

2017-02-24 Thread Ngie Cooper
Author: ngie
Date: Sat Feb 25 03:35:26 2017
New Revision: 314244
URL: https://svnweb.freebsd.org/changeset/base/314244

Log:
  Remove MK_OBJC block
  
  It is no longer represented via src.conf(5)
  
  MFC after:3 days
  Sponsored by: Dell EMC Isilon

Modified:
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:34:22 
2017(r314243)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:35:26 
2017(r314244)
@@ -7014,10 +7014,6 @@ OLD_FILES+=usr/share/man/man8/ntpq.8.gz
 OLD_FILES+=usr/share/man/man8/ntptime.8.gz
 .endif
 
-#.if ${MK_OBJC} == no
-# to be filled in
-#.endif
-
 .if ${MK_OPENSSH} == no
 OLD_FILES+=etc/rc.d/sshd
 OLD_FILES+=etc/ssh/moduli
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314245 - head/tools/build/mk

2017-02-24 Thread Ngie Cooper
Author: ngie
Date: Sat Feb 25 03:44:51 2017
New Revision: 314245
URL: https://svnweb.freebsd.org/changeset/base/314245

Log:
  Fill MK_LIBTHR as far as lib/libthr is concerned
  
  There are other areas of the tree that will need to be evaluated for sanity
  if they're supposed to be conditionally compiled out of the build/install,
  like libzpool
  
  MFC after:1 month
  Relnotes: yes (this might break someone's system if have the knob set)
  Sponsored by: Dell EMC Isilon

Modified:
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:35:26 
2017(r314244)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Sat Feb 25 03:44:51 
2017(r314245)
@@ -4809,9 +4809,12 @@ OLD_DIRS+=usr/include/c++/v1/ext
 OLD_DIRS+=usr/include/c++/v1
 .endif
 
-#.if ${MK_LIBTHR} == no
-# to be filled in
-#.endif
+.if ${MK_LIBTHR} == no
+OLD_LIBS+=lib/libthr.so.3
+OLD_FILES+=usr/lib/libthr.a
+OLD_FILES+=usr/lib/libthr_p.a
+OLD_FILES+=usr/share/man/man3/libthr.3.gz
+.endif
 
 .if ${MK_LLD} == no
 OLD_FILES+=usr/bin/ld.lld
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314246 - head/sys/cam/ctl

2017-02-24 Thread Alexander Motin
Author: mav
Date: Sat Feb 25 04:04:11 2017
New Revision: 314246
URL: https://svnweb.freebsd.org/changeset/base/314246

Log:
  Improve CAM target frontend reference counting.
  
  Before this change it was possible to trigger some use-after-free panics
  by disabling LUNs/ports under heavy load.
  
  MFC after:2 weeks

Modified:
  head/sys/cam/ctl/scsi_ctl.c

Modified: head/sys/cam/ctl/scsi_ctl.c
==
--- head/sys/cam/ctl/scsi_ctl.c Sat Feb 25 03:44:51 2017(r314245)
+++ head/sys/cam/ctl/scsi_ctl.c Sat Feb 25 04:04:11 2017(r314246)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -103,15 +104,11 @@ struct ctlfe_lun_softc {
struct ctlfe_softc *parent_softc;
struct cam_periph *periph;
ctlfe_lun_flags flags;
-   uint64_t ccbs_alloced;
-   uint64_t ccbs_freed;
-   uint64_t ctios_sent;
-   uint64_t ctios_returned;
-   uint64_t atios_alloced;
-   uint64_t atios_freed;
-   uint64_t inots_alloced;
-   uint64_t inots_freed;
-   /* bus_dma_tag_t dma_tag; */
+   int  ctios_sent;/* Number of active CTIOs */
+   int  refcount;  /* Number of active xpt_action() */
+   int  atios_alloced; /* Number of ATIOs not freed */
+   int  inots_alloced; /* Number of INOTs not freed */
+   struct task refdrain_task;
TAILQ_HEAD(, ccb_hdr) work_queue;
STAILQ_ENTRY(ctlfe_lun_softc) links;
 };
@@ -677,18 +674,14 @@ ctlfecleanup(struct cam_periph *periph)
 
softc = (struct ctlfe_lun_softc *)periph->softc;
 
-   KASSERT(softc->ccbs_freed == softc->ccbs_alloced, ("%s: "
-   "ccbs_freed %ju != ccbs_alloced %ju", __func__,
-   softc->ccbs_freed, softc->ccbs_alloced));
-   KASSERT(softc->ctios_returned == softc->ctios_sent, ("%s: "
-   "ctios_returned %ju != ctios_sent %ju", __func__,
-   softc->ctios_returned, softc->ctios_sent));
-   KASSERT(softc->atios_freed == softc->atios_alloced, ("%s: "
-   "atios_freed %ju != atios_alloced %ju", __func__,
-   softc->atios_freed, softc->atios_alloced));
-   KASSERT(softc->inots_freed == softc->inots_alloced, ("%s: "
-   "inots_freed %ju != inots_alloced %ju", __func__,
-   softc->inots_freed, softc->inots_alloced));
+   KASSERT(softc->ctios_sent == 0, ("%s: ctios_sent %d != 0",
+   __func__, softc->ctios_sent));
+   KASSERT(softc->refcount == 0, ("%s: refcount %d != 0",
+   __func__, softc->refcount));
+   KASSERT(softc->atios_alloced == 0, ("%s: atios_alloced %d != 0",
+   __func__, softc->atios_alloced));
+   KASSERT(softc->inots_alloced == 0, ("%s: inots_alloced %d != 0",
+   __func__, softc->inots_alloced));
 
free(softc, M_CTLFE);
 }
@@ -804,12 +797,10 @@ ctlfestart(struct cam_periph *periph, un
uint8_t scsi_status;
 
softc = (struct ctlfe_lun_softc *)periph->softc;
-   softc->ccbs_alloced++;
 
 next:
ccb_h = TAILQ_FIRST(&softc->work_queue);
if (ccb_h == NULL) {
-   softc->ccbs_freed++;
xpt_release_ccb(start_ccb);
return;
}
@@ -931,16 +922,32 @@ next:
io->io_hdr.flags &= ~(CTL_FLAG_DMA_QUEUED | CTL_FLAG_STATUS_QUEUED);
 
softc->ctios_sent++;
-
+   softc->refcount++;
cam_periph_unlock(periph);
xpt_action(start_ccb);
cam_periph_lock(periph);
+   softc->refcount--;
 
/*
 * If we still have work to do, ask for another CCB.
 */
if (!TAILQ_EMPTY(&softc->work_queue))
-   xpt_schedule(periph, /*priority*/ 1);
+   xpt_schedule(periph, CAM_PRIORITY_NORMAL);
+}
+
+static void
+ctlfe_drain(void *context, int pending)
+{
+   struct cam_periph *periph = context;
+   struct ctlfe_lun_softc *softc = periph->softc;
+
+   cam_periph_lock(periph);
+   while (softc->refcount != 0) {
+   cam_periph_sleep(periph, &softc->refcount, PRIBIO,
+   "ctlfe_drain", 1);
+   }
+   cam_periph_unlock(periph);
+   cam_periph_release(periph);
 }
 
 static void
@@ -955,13 +962,13 @@ ctlfe_free_ccb(struct cam_periph *periph
 
switch (ccb->ccb_h.func_code) {
case XPT_ACCEPT_TARGET_IO:
-   softc->atios_freed++;
+   softc->atios_alloced--;
cmd_info = PRIV_INFO(io);
free(cmd_info, M_CTLFE);
break;
case XPT_IMMEDIATE_NOTIFY:
case XPT_NOTIFY_ACKNOWLEDGE:
-   softc->inots_freed++;
+   softc->inots_alloced--;
break;
default:
break;
@@ -970,21 +977,24 @@ ctlfe_free_ccb(struct cam_periph *periph
ctl_free_io(io);
free(ccb, M_CTLFE);
 
-  

svn commit: r314247 - head/sys/cam/ctl

2017-02-24 Thread Alexander Motin
Author: mav
Date: Sat Feb 25 04:24:51 2017
New Revision: 314247
URL: https://svnweb.freebsd.org/changeset/base/314247

Log:
  Axe out some forever disabled questionable functionality.
  
  This code is complicated enough even in its base shape.
  
  MFC after:2 weeks

Modified:
  head/sys/cam/ctl/scsi_ctl.c

Modified: head/sys/cam/ctl/scsi_ctl.c
==
--- head/sys/cam/ctl/scsi_ctl.c Sat Feb 25 04:04:11 2017(r314246)
+++ head/sys/cam/ctl/scsi_ctl.c Sat Feb 25 04:24:51 2017(r314247)
@@ -90,10 +90,6 @@ struct ctlfe_softc {
 STAILQ_HEAD(, ctlfe_softc) ctlfe_softc_list;
 struct mtx ctlfe_list_mtx;
 static char ctlfe_mtx_desc[] = "ctlfelist";
-#ifdef CTLFE_INIT_ENABLE
-static int ctlfe_max_targets = 1;
-static int ctlfe_num_targets = 0;
-#endif
 
 typedef enum {
CTLFE_LUN_NONE  = 0x00,
@@ -152,12 +148,9 @@ struct ctlfe_cmd_info {
 #defineCTLFE_IN_PER_LUN1024
 
 /*
- * Timeout (in seconds) on CTIO CCB allocation for doing a DMA or sending
- * status to the initiator.  The SIM is expected to have its own timeouts,
- * so we're not putting this timeout around the CCB execution time.  The
- * SIM should timeout and let us know if it has an issue.
+ * Timeout (in seconds) on CTIO CCB doing DMA or sending status
  */
-#defineCTLFE_DMA_TIMEOUT   60
+#defineCTLFE_TIMEOUT   5
 
 /*
  * Turn this on to enable extra debugging prints.
@@ -166,15 +159,6 @@ struct ctlfe_cmd_info {
 #defineCTLFE_DEBUG
 #endif
 
-/*
- * Use randomly assigned WWNN/WWPN values.  This is to work around an issue
- * in the FreeBSD initiator that makes it unable to rescan the target if
- * the target gets rebooted and the WWNN/WWPN stay the same.
- */
-#if 0
-#defineRANDOM_WWNN
-#endif
-
 MALLOC_DEFINE(M_CTLFE, "CAM CTL FE", "CAM CTL FE interface");
 
 #defineio_ptr  ppriv_ptr0
@@ -305,49 +289,6 @@ ctlfeasync(void *callback_arg, uint32_t 
break;
}
 
-#ifdef CTLFE_INIT_ENABLE
-   if (ctlfe_num_targets >= ctlfe_max_targets) {
-   union ccb *ccb;
-
-   ccb = (union ccb *)malloc(sizeof(*ccb), M_TEMP,
- M_NOWAIT | M_ZERO);
-   if (ccb == NULL) {
-   printf("%s: unable to malloc CCB!\n", __func__);
-   return;
-   }
-   xpt_setup_ccb(&ccb->ccb_h, path, CAM_PRIORITY_NONE);
-
-   ccb->ccb_h.func_code = XPT_SET_SIM_KNOB;
-   ccb->knob.xport_specific.valid = KNOB_VALID_ROLE;
-   ccb->knob.xport_specific.fc.role = KNOB_ROLE_INITIATOR;
-
-   xpt_action(ccb);
-
-   if ((ccb->ccb_h.status & CAM_STATUS_MASK) !=
-CAM_REQ_CMP) {
-   printf("%s: SIM %s%d (path id %d) initiator "
-  "enable failed with status %#x\n",
-  __func__, cpi->dev_name,
-  cpi->unit_number, cpi->ccb_h.path_id,
-  ccb->ccb_h.status);
-   } else {
-   printf("%s: SIM %s%d (path id %d) initiator "
-  "enable succeeded\n",
-  __func__, cpi->dev_name,
-  cpi->unit_number, cpi->ccb_h.path_id);
-   }
-
-   free(ccb, M_TEMP);
-
-   break;
-   } else {
-   ctlfe_num_targets++;
-   }
-
-   printf("%s: ctlfe_num_targets = %d\n", __func__,
-  ctlfe_num_targets);
-#endif /* CTLFE_INIT_ENABLE */
-
/*
 * We're in an interrupt context here, so we have to
 * use M_NOWAIT.  Of course this means trouble if we
@@ -385,7 +326,7 @@ ctlfeasync(void *callback_arg, uint32_t 
port->port_type = CTL_PORT_SCSI;
 
/* XXX KDM what should the real number be here? */
-   port->num_requested_ctl_io = 4096;
+   port->num_requested_ctl_io = CTLFE_REQ_CTL_IO;
snprintf(softc->port_name, sizeof(softc->port_name),
 "%s%d", cpi->dev_name, cpi->unit_number);
/*
@@ -404,15 +345,7 @@ ctlfeasync(void *callback_arg, uint32_t 
port->fe_datamove = ctlfe_datamove;
port->fe_done = ctlfe_done;
port->targ_port = -1;
-   
-   /*
-* XXX KDM need to figure out whether we're the master or
-* slave.
-*/
-#ifdef CTLFEDEBUG
-   printf("%s: calling ctl_

Re: svn commit: r313268 - head/sys/kern [through -r313271 for atomic_fcmpset use and later: fails on PowerMac G5 "Quad Core"; -r313266 works]

2017-02-24 Thread Mark Millard
On 2017-Feb-24, at 4:23 PM, Mateusz Guzik  wrote:
> 
> On Tue, Feb 21, 2017 at 01:37:25AM -0800, Mark Millard wrote:
>> [Back to the powerpc64 context.]
>> 
>> On 2017-Feb-20, at 11:10 AM, Mateusz Guzik  wrote:
>> 
>>> On Sat, Feb 18, 2017 at 04:18:05AM -0800, Mark Millard wrote:
 [Note: I experiment with clang based powerpc64 builds,
 reporting problems that I find. Justin is familiar
 with this, as is Nathan.]
 
 I tried to update the PowerMac G5 (a so-called "Quad Core")
 that I have access to from head -r312761 to -r313864 and
 ended up with random panics and hang ups in fairly short
 order after booting.
 
 Some approximate bisecting for the kernel lead to:
 (sometimes getting part way into a buildkernel attempt
 for a different version before a failure happens)
 
 -r313266: works (just before use of atomic_fcmpset)
 vs.
 -r313271: fails (last of the "use atomic_fcmpset" check-ins)
 
 (I did not try -r313268 through -r313270 as the use was
 gradually added.)
 
 So I'm currently running a -r313864 world with a -r313266
 kernel.
 
 No kernel that I tried that was from before -r313266 had the
 problems.
 
 Any kernel that I tried that was from after -r313271 had the
 problems.
 
 Of course I did not try them all in other direction. :)
 
>>> 
>>> I found that spin mutexes were not properly handling this, fixed in
>>> r313996.
>>> 
>>> Locally I added a if (cpu_tick() % 2) return (0); snipped to amd64
>>> fcmpset to simulate failures. Everything works, while it would easily
>>> fail without the patch.
>>> 
>>> That said, I hope this concludes the 'missing check for not-reread value
>>> of failed fcmpset' saga.
>>> 
>>> -- 
>>> Mateusz Guzik 
>> 
>> -r313999 is an improvement for powerpc64: it boots and I can
>> log in on the old PowerMac G5 so-called "Quad Core".
>> 
>> But, e.g., buildworld buildkernel eventually hangs and later
>> the powerpc64 panics for "spin lock held too long".
>> 
> 
> Allright, play time is over.
> 
> Can you please:
> 1. verify r313254 is stable for you
> 2. apply https://people.freebsd.org/~mjg/patches/complete-locks.diff and
> https://people.freebsd.org/~mjg/.junk/ppc.diff on top of it and retry
> the test?
> 
> This is a workaround which effectively disables the powerpc-specific
> primitive and makes it use a cmpset wrapper instead. I don't have the
> hardware to test right now and my attempts to boot in qemu also failed.
> 
> That said, does not look like there are general fcmpset bugs left and
> the remaining issue seems powerpc-specific.
> 
> If this works, I'll commit the workaround for the time being as in few
> weeks I'd like to start merging the work back to stable/11.
> 
> -- 
> Mateusz Guzik 

I've started a self-hosted powerpc64 -r313254 build
based on running the -r313266 kernel. (The context 
sometimes do cross builds in is tied up with other
things. -r313266 is what my prior bisection came up
with as the last appearently-working kernel at the
time.)

So it will be a while before I have a -r313254 in
place to try: the self-hosted build takes longer
and so will not be installed for a while.

To judge stability I'll probably have -e313254 build
the patched update that you want me to test, initially
doing a cleanworld. So that too will take a while.

(The above wording presumes all goes well.)

I'll let you know as I go along if I run into anything
interesting.


My builds are rebuilding both world and kernel since
what turns into /usr/include/sys/* has changes in your
patch.

The builds are without MALLOC_PRODUCTION but are
otherwise not debug builds.


I've not seen anything indicating that anyone has
been trying TARGET_ARCH=powerpc. I've been trying
TARGET_ARCH=powerpc64 .

While I do not have access to a true
TARGET_ARCH=powerpc machine currently, such a build
can be used on a PowerMac G5 so-called "Quad Core".
So I could eventually build and try such on the one
powerpc family machine that I currently have access
to.

clang 3.9.1 has a significant code generation problem
for TARGET_ARCH=powerpc and so I'd have to use
a gcc 4.2.1 based build for that sort of experiment.
(There is no xtoolchain for 32-bit powerpc.)

I use clang 3.9.1 or xtoolchain for
TARGET_ARCH=powerpc64 and have been using clang 3.9.1
in recent times. My primary powerpc family use has
been to experiment with building based on the
modern libc++ and reporting issues discovered in the
attempts. This explains the clang/xtoolchain context.

clang 3.9.1 has major problems for C++ exception
handling for both powerpc64 and powerpc but a
lot of FreeBSD is independent of throwing C++
exceptions. By contrast xtoolchain-based works
for C++ exception handling but lib32 fails
to operate when built by a xtoolchain build.

===
Mark Millard
markmi at dsl-only.net

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/s

svn commit: r314248 - head/sys/dev/pci

2017-02-24 Thread Warner Losh
Author: imp
Date: Sat Feb 25 06:11:36 2017
New Revision: 314248
URL: https://svnweb.freebsd.org/changeset/base/314248

Log:
  Create pcib_request_feature.
  
  pcib_request_feature allows drivers to request the firmware (ACPI)
  release certain features it may be using. ACPI normally manages things
  like hot plug, advanced error reporting and other features until the
  OS requests ACPI to relenquish control since it is taking over.
  
  Sponsored by: Netflix

Modified:
  head/sys/dev/pci/pci_if.m
  head/sys/dev/pci/pci_pci.c
  head/sys/dev/pci/pcib_if.m

Modified: head/sys/dev/pci/pci_if.m
==
--- head/sys/dev/pci/pci_if.m   Sat Feb 25 04:24:51 2017(r314247)
+++ head/sys/dev/pci/pci_if.m   Sat Feb 25 06:11:36 2017(r314248)
@@ -60,6 +60,11 @@ HEADER {
PCI_ID_RID,
PCI_ID_MSI,
};
+
+   enum pci_feature {
+   PCI_FEATURE_HP, /* Hot Plug feature */
+   PCI_FEATURE_AER,/* Advanced Error Reporting */
+   };
 }
 
 

Modified: head/sys/dev/pci/pci_pci.c
==
--- head/sys/dev/pci/pci_pci.c  Sat Feb 25 04:24:51 2017(r314247)
+++ head/sys/dev/pci/pci_pci.c  Sat Feb 25 06:11:36 2017(r314248)
@@ -76,6 +76,8 @@ static void   pcib_pcie_ab_timeout(void *
 static voidpcib_pcie_cc_timeout(void *arg);
 static voidpcib_pcie_dll_timeout(void *arg);
 #endif
+static int pcib_request_feature(device_t pcib, device_t dev,
+   enum pci_feature feature);
 
 static device_method_t pcib_methods[] = {
 /* Device interface */
@@ -119,6 +121,7 @@ static device_method_t pcib_methods[] = 
 DEVMETHOD(pcib_try_enable_ari, pcib_try_enable_ari),
 DEVMETHOD(pcib_ari_enabled,pcib_ari_enabled),
 DEVMETHOD(pcib_decode_rid, pcib_ari_decode_rid),
+DEVMETHOD(pcib_request_feature,pcib_request_feature),
 
 DEVMETHOD_END
 };
@@ -2829,3 +2832,24 @@ pcib_try_enable_ari(device_t pcib, devic
 
return (0);
 }
+
+/*
+ * Pass the request to use this PCI feature up the tree. Either there's a
+ * firmware like ACPI that's using this feature that will approve (or deny) the
+ * request to take it over, or the platform has no such firmware, in which case
+ * the request will be approved. If the request is approved, the OS is expected
+ * to make use of the feature or render it harmless.
+ */
+static int
+pcib_request_feature(device_t pcib, device_t dev, enum pci_feature feature)
+{
+   device_t bus;
+
+   /*
+* Our parent is necessarily a pci bus. Its parent will either be
+* another pci bridge (which passes it up) or a host bridge that can
+* approve or reject the request.
+*/
+   bus = device_get_parent(pcib);
+   return (PCIB_REQUEST_FEATURE(device_get_parent(bus), dev, feature));
+}

Modified: head/sys/dev/pci/pcib_if.m
==
--- head/sys/dev/pci/pcib_if.m  Sat Feb 25 04:24:51 2017(r314247)
+++ head/sys/dev/pci/pcib_if.m  Sat Feb 25 06:11:36 2017(r314248)
@@ -212,3 +212,12 @@ METHOD void decode_rid {
int *slot;
int *func;
 } DEFAULT pcib_decode_rid;
+
+#
+# Request control of PCI features from host firmware, if any.
+#
+METHOD int request_feature {
+   device_tpcib;
+   device_tdev;
+   enum pci_feature feature;
+};
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314249 - head/sys/dev/pci

2017-02-24 Thread Warner Losh
Author: imp
Date: Sat Feb 25 06:11:50 2017
New Revision: 314249
URL: https://svnweb.freebsd.org/changeset/base/314249

Log:
  Rename pci_pcie_intr to pci_pcie_intr_hotplug.
  
  Sponsored by: Netflix

Modified:
  head/sys/dev/pci/pci_pci.c

Modified: head/sys/dev/pci/pci_pci.c
==
--- head/sys/dev/pci/pci_pci.c  Sat Feb 25 06:11:36 2017(r314248)
+++ head/sys/dev/pci/pci_pci.c  Sat Feb 25 06:11:50 2017(r314249)
@@ -1148,7 +1148,7 @@ pcib_pcie_hotplug_update(struct pcib_sof
 }
 
 static void
-pcib_pcie_intr(void *arg)
+pcib_pcie_intr_hotplug(void *arg)
 {
struct pcib_softc *sc;
device_t dev;
@@ -1261,7 +1261,7 @@ pcib_pcie_cc_timeout(void *arg)
} else {
device_printf(dev,
"Missed HotPlug interrupt waiting for Command Completion\n");
-   pcib_pcie_intr(sc);
+   pcib_pcie_intr_hotplug(sc);
}
 }
 
@@ -1284,7 +1284,7 @@ pcib_pcie_dll_timeout(void *arg)
} else if (sta != sc->pcie_link_sta) {
device_printf(dev,
"Missed HotPlug interrupt waiting for DLL Active\n");
-   pcib_pcie_intr(sc);
+   pcib_pcie_intr_hotplug(sc);
}
 }
 
@@ -1330,7 +1330,7 @@ pcib_alloc_pcie_irq(struct pcib_softc *s
}
 
error = bus_setup_intr(dev, sc->pcie_irq, INTR_TYPE_MISC,
-   NULL, pcib_pcie_intr, sc, &sc->pcie_ihand);
+   NULL, pcib_pcie_intr_hotplug, sc, &sc->pcie_ihand);
if (error) {
device_printf(dev, "Failed to setup PCI-e interrupt handler\n");
bus_release_resource(dev, SYS_RES_IRQ, rid, sc->pcie_irq);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314250 - in head/sys: arm/mv arm/nvidia arm/versatile arm/xscale/i8134x arm/xscale/ixp425 dev/acpica dev/hyperv/pcib dev/ofw dev/pci dev/xen/pcifront mips/adm5120 mips/atheros mips/cav...

2017-02-24 Thread Warner Losh
Author: imp
Date: Sat Feb 25 06:11:59 2017
New Revision: 314250
URL: https://svnweb.freebsd.org/changeset/base/314250

Log:
  Convert PCIe Hot Plug to using pci_request_feature
  
  Convert PCIe hot plug support over to asking the firmware, if any, for
  permission to use the HotPlug hardware. Implement pci_request_feature
  for ACPI. All other host pci connections to allowing all valid feature
  requests.
  
  Sponsored by: Netflix

Modified:
  head/sys/arm/mv/mv_pci.c
  head/sys/arm/nvidia/tegra_pcie.c
  head/sys/arm/versatile/versatile_pci.c
  head/sys/arm/xscale/i8134x/i81342_pci.c
  head/sys/arm/xscale/ixp425/ixp425_pci.c
  head/sys/dev/acpica/acpi_pcib_acpi.c
  head/sys/dev/hyperv/pcib/vmbus_pcib.c
  head/sys/dev/ofw/ofwpci.c
  head/sys/dev/pci/pci_host_generic_fdt.c
  head/sys/dev/pci/pci_pci.c
  head/sys/dev/pci/pcib_private.h
  head/sys/dev/xen/pcifront/pcifront.c
  head/sys/mips/adm5120/admpci.c
  head/sys/mips/atheros/ar71xx_pci.c
  head/sys/mips/atheros/ar724x_pci.c
  head/sys/mips/atheros/qca955x_pci.c
  head/sys/mips/cavium/octopci.c
  head/sys/mips/idt/idtpci.c
  head/sys/mips/malta/gt_pci.c
  head/sys/mips/mediatek/mtk_pcie.c
  head/sys/mips/nlm/xlp_pci.c
  head/sys/mips/rmi/xlr_pci.c
  head/sys/mips/rt305x/rt305x_pci.c
  head/sys/mips/sibyte/sb_zbpci.c
  head/sys/powerpc/ofw/ofw_pcib_pci.c
  head/sys/powerpc/powermac/cpcht.c
  head/sys/sparc64/pci/apb.c
  head/sys/sparc64/pci/fire.c
  head/sys/sparc64/pci/ofw_pcib.c
  head/sys/sparc64/pci/psycho.c
  head/sys/sparc64/pci/schizo.c
  head/sys/x86/pci/pci_bus.c

Modified: head/sys/arm/mv/mv_pci.c
==
--- head/sys/arm/mv/mv_pci.cSat Feb 25 06:11:50 2017(r314249)
+++ head/sys/arm/mv/mv_pci.cSat Feb 25 06:11:59 2017(r314250)
@@ -368,7 +368,7 @@ static device_method_t mv_pcib_methods[]
DEVMETHOD(pcib_read_config, mv_pcib_read_config),
DEVMETHOD(pcib_write_config,mv_pcib_write_config),
DEVMETHOD(pcib_route_interrupt, mv_pcib_route_interrupt),
-
+   DEVMETHOD(pcib_request_feature, pcib_request_feature_allow),
 #if defined(SOC_MV_ARMADAXP)
DEVMETHOD(pcib_alloc_msi,   mv_pcib_alloc_msi),
DEVMETHOD(pcib_release_msi, mv_pcib_release_msi),

Modified: head/sys/arm/nvidia/tegra_pcie.c
==
--- head/sys/arm/nvidia/tegra_pcie.cSat Feb 25 06:11:50 2017
(r314249)
+++ head/sys/arm/nvidia/tegra_pcie.cSat Feb 25 06:11:59 2017
(r314250)
@@ -1601,6 +1601,7 @@ static device_method_t tegra_pcib_method
DEVMETHOD(pcib_alloc_msi,   tegra_pcib_alloc_msi),
DEVMETHOD(pcib_release_msi, tegra_pcib_release_msi),
DEVMETHOD(pcib_map_msi, tegra_pcib_map_msi),
+   DEVMETHOD(pcib_request_feature, pcib_request_feature_allow),
 
 #ifdef TEGRA_PCIB_MSI_ENABLE
/* MSI/MSI-X */

Modified: head/sys/arm/versatile/versatile_pci.c
==
--- head/sys/arm/versatile/versatile_pci.c  Sat Feb 25 06:11:50 2017
(r314249)
+++ head/sys/arm/versatile/versatile_pci.c  Sat Feb 25 06:11:59 2017
(r314250)
@@ -505,6 +505,7 @@ static device_method_t versatile_pci_met
DEVMETHOD(pcib_read_config, versatile_pci_read_config),
DEVMETHOD(pcib_write_config,versatile_pci_write_config),
DEVMETHOD(pcib_route_interrupt, versatile_pci_route_interrupt),
+   DEVMETHOD(pcib_request_feature, pcib_request_feature_allow),
 
DEVMETHOD_END
 };

Modified: head/sys/arm/xscale/i8134x/i81342_pci.c
==
--- head/sys/arm/xscale/i8134x/i81342_pci.c Sat Feb 25 06:11:50 2017
(r314249)
+++ head/sys/arm/xscale/i8134x/i81342_pci.c Sat Feb 25 06:11:59 2017
(r314250)
@@ -529,6 +529,7 @@ static device_method_t i81342_pci_method
DEVMETHOD(pcib_read_config, i81342_pci_read_config),
DEVMETHOD(pcib_write_config,i81342_pci_write_config),
DEVMETHOD(pcib_route_interrupt, i81342_pci_route_interrupt),
+   DEVMETHOD(pcib_request_feature, pcib_request_feature_allow),
 
DEVMETHOD_END
 };

Modified: head/sys/arm/xscale/ixp425/ixp425_pci.c
==
--- head/sys/arm/xscale/ixp425/ixp425_pci.c Sat Feb 25 06:11:50 2017
(r314249)
+++ head/sys/arm/xscale/ixp425/ixp425_pci.c Sat Feb 25 06:11:59 2017
(r314250)
@@ -466,6 +466,7 @@ static device_method_t ixppcib_methods[]
DEVMETHOD(pcib_read_config, ixppcib_read_config),
DEVMETHOD(pcib_write_config,ixppcib_write_config),
DEVMETHOD(pcib_route_interrupt, ixppcib_route_interrupt),
+   DEVMETHOD(pcib_reques

Re: svn commit: r314142 - head/sys/dev/ce

2017-02-24 Thread Gleb Smirnoff
On Thu, Feb 23, 2017 at 06:31:45PM -0700, Warner Losh wrote:
W> On Thu, Feb 23, 2017 at 5:28 PM, Gleb Smirnoff  wrote:
W> > On Thu, Feb 23, 2017 at 03:30:21PM +, Pedro F. Giffuni wrote:
W> > P> Author: pfg
W> > P> Date: Thu Feb 23 15:30:21 2017
W> > P> New Revision: 314142
W> > P> URL: https://svnweb.freebsd.org/changeset/base/314142
W> > P>
W> > P> Log:
W> > P>   dev/ce: double assignment.
W> > P>
W> > P>   The code is not operational right now so just comment away an 
obviously
W> > P>   useless assignment. Fix some typos while here.
W> > P>
W> > P>   Found with: coccinelle (da.cocci)
W> >
W> > What is interesting is that vendor still exists and sells the hardware, but
W> > explicitly says "FreeBSD 7.x isn't supported" :)
W> >
W> > http://cronyx.ru/hardware/tau32.html
W> >
W> > I don't see any reasons for the driver to get broken between 6.0 and 7.0.
W> 
W> Murray Stokely was the contact for this hardware. I think he gave it
W> to me years ago, but I just checked and I can't find it in the usual
W> places. IIRC, they were ISA cards though, not PCI...

He probably brought one from Moscow 10 years ago. :) There was ISA version
even earlier, and it had driver for FreeBSD, but AFAIK the driver never
made it to the tree. At the moment when rik@ got commit bit, Cronyx was
producing and supporing only PCI Taus.

-- 
Totus tuus, Glebius.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r278729 - head/sys/sys

2017-02-24 Thread Gleb Smirnoff
On Fri, Feb 17, 2017 at 11:06:21AM -0800, hiren panchasara wrote:
h> On 03/19/15 at 11:08P, hiren panchasara wrote:
h> > On 03/16/15 at 06:06P, hiren panchasara wrote:
h> > > On 03/16/15 at 03:39P, Gleb Smirnoff wrote:
h> > > > On Wed, Mar 11, 2015 at 02:36:07PM -0700, hiren panchasara wrote:
h> > > > h> On 02/13/15 at 11:19P, Simon J. Gerraty wrote:
h> > > > h> > Author: sjg
h> > > > h> > Date: Fri Feb 13 23:19:35 2015
h> > > > h> > New Revision: 278729
h> > > > h> > URL: https://svnweb.freebsd.org/changeset/base/278729
h> > > > h> > 
h> > > > h> > Log:
h> > > > h> >   sbspace: size of bleft, mleft must match sockbuf fields to avoid
h> > > > h> >   overflow on amd64
h> > > > h> >   
h> > > > h> >   Submitted by:   anshu...@juniper.net
h> > > > h> >   Obtained from:  Juniper Networks
h> > > > h> 
h> > > > h> Talking to sjg on -arch to MFC this. If he cannot get around doing 
that,
h> > > > h> I'll do it tomorrow. 
h> > > > h> 
h> > > > h> Letting people know here to see if there are any objections.
h> > > > 
h> > > > Would that fix the bug we've been discussing?
h> > > 
h> > > Unsure as I am not sure what caused the issue I saw.
h> > > 
h> > > For those who do not know the details, we recently saw a userland
h> > > process stuck spinning at 100% around sbcut_internal(). Inside
h> > > sbflush_internal(), the sb_cc was grown to be about 4G. And before
h> > > passing it to sbcut_internal(), we cast it from uint to int which
h> > > would make that valud -ve.
h> > > 
h> > > Gleb pointed out to me that sbspace() is supposed to check/stop sb_cc
h> > > from growing that large.
h> > > 
h> > > Now, I am not sure if we'd ever run into this situation again but
h> > > current fix is a great catch anyways.
h> > > 
h> > > I still have 2 questions around what we saw. It'd be great if someone can
h> > > clarify them for my understanding:
h> > > 
h> > > 1) Even if we get into such a scenario that we were in, following would
h> > > help by not looping endlessly.
h> > > 
h> > > --- uipc_sockbuf.c.02015-03-11 15:49:52.0 -0700
h> > > +++ uipc_sockbuf.c  2015-03-11 15:51:48.0 -0700
h> > > @@ -877,6 +877,9 @@
h> > > {
h> > >  struct mbuf *m, *n, *next, *mfree;
h> > > 
h> > > +  if (len < 0)
h> > > +   panic("%s: len is %d and it is supposed to be +ve",
h> > > +__func__, len);
h> > > +
h> > >  next = (m = sb->sb_mb) ? m->m_nextpkt : 0;
h> > >  mfree = NULL
h> > > 
h> > > 2) We need 1) because we are casting a uint to int which _may_ rander a
h> > > value -ve. Is there a way we can avoid the casting?
h> > 
h> > It'd be useful if someone with knowledge in this area can weigh in.
h> 
h> Ran into this again today. While the real question of how sb_ccc grew
h> this large is still unsolved, any objection to adding this patch to
h> avoid a hang and panic instead?

I am all for adding KASSERT now and then fixing the bug.

-- 
Totus tuus, Glebius.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r313268 - head/sys/kern [through -r313271 for atomic_fcmpset use and later: fails on PowerMac G5 "Quad Core"; -r313266 works]

2017-02-24 Thread Mark Millard
On 2017-Feb-24, at 8:25 PM, Mark Millard  wrote:

> On 2017-Feb-24, at 4:23 PM, Mateusz Guzik  wrote:
>> 
>> On Tue, Feb 21, 2017 at 01:37:25AM -0800, Mark Millard wrote:
>>> [Back to the powerpc64 context.]
>>> 
>>> On 2017-Feb-20, at 11:10 AM, Mateusz Guzik  wrote:
>>> 
 On Sat, Feb 18, 2017 at 04:18:05AM -0800, Mark Millard wrote:
> [Note: I experiment with clang based powerpc64 builds,
> reporting problems that I find. Justin is familiar
> with this, as is Nathan.]
> 
> I tried to update the PowerMac G5 (a so-called "Quad Core")
> that I have access to from head -r312761 to -r313864 and
> ended up with random panics and hang ups in fairly short
> order after booting.
> 
> Some approximate bisecting for the kernel lead to:
> (sometimes getting part way into a buildkernel attempt
> for a different version before a failure happens)
> 
> -r313266: works (just before use of atomic_fcmpset)
> vs.
> -r313271: fails (last of the "use atomic_fcmpset" check-ins)
> 
> (I did not try -r313268 through -r313270 as the use was
> gradually added.)
> 
> So I'm currently running a -r313864 world with a -r313266
> kernel.
> 
> No kernel that I tried that was from before -r313266 had the
> problems.
> 
> Any kernel that I tried that was from after -r313271 had the
> problems.
> 
> Of course I did not try them all in other direction. :)
> 
 
 I found that spin mutexes were not properly handling this, fixed in
 r313996.
 
 Locally I added a if (cpu_tick() % 2) return (0); snipped to amd64
 fcmpset to simulate failures. Everything works, while it would easily
 fail without the patch.
 
 That said, I hope this concludes the 'missing check for not-reread value
 of failed fcmpset' saga.
 
 -- 
 Mateusz Guzik 
>>> 
>>> -r313999 is an improvement for powerpc64: it boots and I can
>>> log in on the old PowerMac G5 so-called "Quad Core".
>>> 
>>> But, e.g., buildworld buildkernel eventually hangs and later
>>> the powerpc64 panics for "spin lock held too long".
>>> 
>> 
>> Allright, play time is over.
>> 
>> Can you please:
>> 1. verify r313254 is stable for you
>> 2. apply https://people.freebsd.org/~mjg/patches/complete-locks.diff and
>> https://people.freebsd.org/~mjg/.junk/ppc.diff on top of it and retry
>> the test?
>> 
>> This is a workaround which effectively disables the powerpc-specific
>> primitive and makes it use a cmpset wrapper instead. I don't have the
>> hardware to test right now and my attempts to boot in qemu also failed.
>> 
>> That said, does not look like there are general fcmpset bugs left and
>> the remaining issue seems powerpc-specific.
>> 
>> If this works, I'll commit the workaround for the time being as in few
>> weeks I'd like to start merging the work back to stable/11.
>> 
>> -- 
>> Mateusz Guzik 
> 
> I've started a self-hosted powerpc64 -r313254 build
> based on running the -r313266 kernel. (The context 
> sometimes do cross builds in is tied up with other
> things. -r313266 is what my prior bisection came up
> with as the last appearently-working kernel at the
> time.)
> 
> So it will be a while before I have a -r313254 in
> place to try: the self-hosted build takes longer
> and so will not be installed for a while.
> 
> To judge stability I'll probably have -e313254 build
> the patched update that you want me to test, initially
> doing a cleanworld. So that too will take a while.
> 
> (The above wording presumes all goes well.)
> 
> I'll let you know as I go along if I run into anything
> interesting.
> 
> 
> My builds are rebuilding both world and kernel since
> what turns into /usr/include/sys/* has changes in your
> patch.
> 
> The builds are without MALLOC_PRODUCTION but are
> otherwise not debug builds.
> 
> 
> I've not seen anything indicating that anyone has
> been trying TARGET_ARCH=powerpc. I've been trying
> TARGET_ARCH=powerpc64 .
> 
> While I do not have access to a true
> TARGET_ARCH=powerpc machine currently, such a build
> can be used on a PowerMac G5 so-called "Quad Core".
> So I could eventually build and try such on the one
> powerpc family machine that I currently have access
> to.
> 
> clang 3.9.1 has a significant code generation problem
> for TARGET_ARCH=powerpc and so I'd have to use
> a gcc 4.2.1 based build for that sort of experiment.
> (There is no xtoolchain for 32-bit powerpc.)
> 
> I use clang 3.9.1 or xtoolchain for
> TARGET_ARCH=powerpc64 and have been using clang 3.9.1
> in recent times. My primary powerpc family use has
> been to experiment with building based on the
> modern libc++ and reporting issues discovered in the
> attempts. This explains the clang/xtoolchain context.
> 
> clang 3.9.1 has major problems for C++ exception
> handling for both powerpc64 and powerpc but a
> lot of FreeBSD is independent of throwing C++
> exceptions. By contrast xtoolchain-based works
> for C++ excep

Re: svn commit: r314216 - head/sys/x86/x86

2017-02-24 Thread Andriy Gapon
On 24/02/2017 20:56, Jonathan T. Looney wrote:
> Author: jtl
> Date: Fri Feb 24 18:56:00 2017
> New Revision: 314216
> URL: https://svnweb.freebsd.org/changeset/base/314216
> 
> Log:
>   We have seen several cases recently where we appear to get a double-fault:
>   We have an original panic. Then, instead of writing the core to the dump
>   device, the kernel has a second panic: "smp_targeted_tlb_shootdown:
>   interrupts disabled". This change is an attempt to fix that second panic.

Just curious if you were able to find out what code caused those shootdowns to
be sent.
It's pretty unusual for the after-panic code to do things like that.


>   When the other CPUs are stopped, we can't notify them of the TLB shootdown,
>   so we skip that operation. However, when the CPUs come back up, we
>   invalidate the TLB to ensure they correctly observe any changes to the
>   page mappings.
>   
>   Reviewed by:kib
>   Sponsored by:   Netflix
>   Differential Revision:  https://reviews.freebsd.org/D9786
> 
> Modified:
>   head/sys/x86/x86/mp_x86.c
> 
> Modified: head/sys/x86/x86/mp_x86.c
> ==
> --- head/sys/x86/x86/mp_x86.c Fri Feb 24 17:36:55 2017(r314215)
> +++ head/sys/x86/x86/mp_x86.c Fri Feb 24 18:56:00 2017(r314216)
> @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
>  #ifdef GPROF 
>  #include 
>  #endif
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1269,6 +1270,12 @@ cpustop_handler_post(u_int cpu)
>   CPU_CLR_ATOMIC(cpu, &started_cpus);
>   CPU_CLR_ATOMIC(cpu, &stopped_cpus);
>  
> + /*
> +  * We don't broadcast TLB invalidations to other CPUs when they are
> +  * stopped. Hence, we clear the TLB before resuming.
> +  */
> + invltlb_glob();
> +
>  #if defined(__amd64__) && defined(DDB)
>   amd64_db_resume_dbreg();
>  #endif
> @@ -1427,6 +1434,10 @@ smp_targeted_tlb_shootdown(cpuset_t mask
>   uint32_t generation;
>   int cpu;
>  
> + /* It is not necessary to signal other CPUs while in the debugger. */
> + if (kdb_active || panicstr != NULL)
> + return;
> +
>   /*
>* Check for other cpus.  Return if none.
>*/
> 


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


Re: svn commit: r314239 - head/rescue/rescue

2017-02-24 Thread Andriy Gapon
On 25/02/2017 05:11, Ngie Cooper wrote:
> Author: ngie
> Date: Sat Feb 25 03:11:08 2017
> New Revision: 314239
> URL: https://svnweb.freebsd.org/changeset/base/314239
> 
> Log:
>   Add shutdown/poweroff support to rescue(8)
>   
>   shutdown is a safer way to power off than reboot (in general), because of
>   the added shutdown process that it executes via /etc/rc.shutdown . It was
>   odd that it was missing from rescue(8) since reboot and friends were
>   added in past commits.

Just a note that rescue is typically used in situations where rc.shutdown is of
little use.  E.g., most likely there won't be any daemons running, etc.

>   While here, alias poweroff to shutdown for parity with 
> sbin/shutdown/Makefile
>   
>   MFC after:  2 weeks
>   Sponsored by:   Dell EMC Isilon
> 
> Modified:
>   head/rescue/rescue/Makefile
> 
> Modified: head/rescue/rescue/Makefile
> ==
> --- head/rescue/rescue/Makefile   Sat Feb 25 01:53:45 2017
> (r314238)
> +++ head/rescue/rescue/Makefile   Sat Feb 25 03:11:08 2017
> (r314239)
> @@ -99,7 +99,7 @@ CRUNCH_PROGS_sbin= badsect  
> \
>   mount_udf mount_unionfs newfs   \
>   newfs_msdos nos-tun ping reboot \
>   restore rcorder route routed rtquery rtsol savecore \
> - spppcontrol swapon sysctl tunefs umount
> + shutdown spppcontrol swapon sysctl tunefs umount
>  
>  .if ${MK_ATM} != "no"
>  CRUNCH_PROGS_sbin+= atmconfig
> @@ -166,6 +166,7 @@ CRUNCH_ALIAS_restore= rrestore
>  CRUNCH_ALIAS_dump= rdump
>  CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
>  CRUNCH_ALIAS_geom= glabel gpart
> +CRUNCH_ALIAS_shutdown= poweroff
>  
>  # dhclient has historically been troublesome...
>  CRUNCH_PROGS_sbin+= dhclient
> 


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