Re: svn commit: r292894 - in head: sys/kern sys/sys tests/sys/kern
On Tuesday, December 29, 2015 11:25:26 PM John Baldwin wrote: > Author: jhb > Date: Tue Dec 29 23:25:26 2015 > New Revision: 292894 > URL: https://svnweb.freebsd.org/changeset/base/292894 > > Log: > Add ptrace(2) reporting for LWP events. > > Add two new LWPINFO flags: PL_FLAG_BORN and PL_FLAG_EXITED for reporting > thread creation and destruction. Newly created threads will stop to report > PL_FLAG_BORN before returning to userland and exiting threads will stop to > report PL_FLAG_EXIT before exiting completely. Both of these events are > only enabled and reported if PT_LWP_EVENTS is enabled on a process. Bah, should have included: Reviewed by:kib Differential Revision: https://reviews.freebsd.org/D4703 I also noticed right after committing that this is missing the manpage updates. Those will come shortly. -- John Baldwin ___ 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: r292772 - head/sys/vm
On Tue, Dec 29, 2015 at 11:59:52PM +0300, Gleb Smirnoff wrote: > On Sun, Dec 27, 2015 at 02:42:39PM +, Konstantin Belousov wrote: > K> Author: kib > K> Date: Sun Dec 27 14:42:39 2015 > K> New Revision: 292772 > K> URL: https://svnweb.freebsd.org/changeset/base/292772 > K> > K> Log: > K> Add missed relpbuf() for a smallfs page-in. > K> > K> Reported by: Shawn Webb > K> Tested by: pho > K> Sponsored by:The FreeBSD Foundation > K> > K> Modified: > K> head/sys/vm/vnode_pager.c > K> > K> Modified: head/sys/vm/vnode_pager.c > K> > == > K> --- head/sys/vm/vnode_pager.c Sun Dec 27 14:39:47 2015 > (r292771) > K> +++ head/sys/vm/vnode_pager.c Sun Dec 27 14:42:39 2015 > (r292772) > K> @@ -806,6 +806,7 @@ vnode_pager_generic_getpages(struct vnod > K> * than a page size, then use special small filesystem code. > K> */ > K>if (pagesperblock == 0) { > K> + relpbuf(bp, freecnt); > K>for (i = 0; i < count; i++) { > K>PCPU_INC(cnt.v_vnodein); > K>PCPU_INC(cnt.v_vnodepgsin); > > The reason for this bug is that I tried to move the (pagesperblock == 0) > block above the call to getpbuf(). > > We actually know that filesystem is "small" at the very beginning of the > function and we can branch into "small filesystem" pager immediately. > > Later I moved the block back to its place, simply because new place > wasn't tested properly. And forgot to restore relpbuf. > > What filesystem did you use to show up the bug? I'm about to test the > variant with immediate branching. Shawn, would you be able to test > a patch if I produce one? Definitely. Send me a patch and I can spin up an ISO with it and boot it up in bhyve. Thanks, -- Shawn Webb HardenedBSD GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE signature.asc Description: PGP signature
svn commit: r292896 - head/lib/libc/sys
Author: jhb Date: Wed Dec 30 00:04:57 2015 New Revision: 292896 URL: https://svnweb.freebsd.org/changeset/base/292896 Log: Document the recently added support for ptrace(2) LWP events. Modified: head/lib/libc/sys/ptrace.2 Modified: head/lib/libc/sys/ptrace.2 == --- head/lib/libc/sys/ptrace.2 Wed Dec 30 00:04:33 2015(r292895) +++ head/lib/libc/sys/ptrace.2 Wed Dec 30 00:04:57 2015(r292896) @@ -2,7 +2,7 @@ .\"$NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. -.Dd October 20, 2015 +.Dd December 29, 2015 .Dt PTRACE 2 .Os .Sh NAME @@ -372,6 +372,20 @@ The flag is set for first event reported automatically attached due to .Dv PT_FOLLOW_FORK enabled. +.It PL_FLAG_BORN +This flag is set for the first event reported from a new LWP when LWP +events are enabled via +.Dv PT_LWP_EVENTS . +It is reported along with +.Dv PL_FLAG_SCX +and is always reported if LWP events are enabled. +.It PL_FLAG_EXITED +This flag is set for the last event reported by an exiting LWP when +LWP events are enabled via +.Dv PT_LWP_EVENTS . +Note that this event is not reported when the last LWP in a process exits. +The termination of the last thread is reported via a normal process exit +event. .El .It pl_sigmask The current signal mask of the LWP @@ -463,6 +477,29 @@ Child processes do not inherit this prop The traced process will set the .Dv PL_FLAG_FORKED flag upon exit from a system call that creates a new process. +.It PT_LWP_EVENTS +This request controls tracing of LWP creation and destruction. +If +.Fa data +is non-zero, +then LWPs will stop to report creation and destruction events. +If +.Fa data +is zero, +then LWP creation and destruction events will not be reported. +By default, tracing is not enabled for LWP events. +Child processes do not inherit this property. +New LWPs will stop to report an event with +.Dv PL_FLAG_BORN +set before executing their first instruction. +Exiting LWPs will stop to report an event with +.Dv PL_FLAG_EXITED +set before completing their termination. +.Pp +Note that new processes do not report an event for the creation of their +initial thread, +and exiting processes do not report an event for the termination of the +last thread. .It PT_VM_TIMESTAMP This request returns the generation number or timestamp of the memory map of the traced process as the return value from ___ 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: r292809 - head/lib/libc/stdio
On Tue, 29 Dec 2015, John Baldwin wrote: On Monday, December 28, 2015 01:01:26 PM Warner Losh wrote: I'll look at that, but I don't think posix_memalign is the right way to go. The alignment of FILE is more strict than posix_memalign will return. Ian's idea of __alignof__ is the way to go. We allocate them in one block on purpose for performance, and posix_memalign would be a one at a time affair. posix_memalign gives you whatever alignment you ask for. Using __alignof__ to determine the alignment instead of hardcoding sizeof(int64_t) would certainly be an improvement. If you move the glue after the FILE objects then you can use posix_memalign() directly as so: void *mem; int error; error = posix_memalign(&mem, MAX(ALIGNBYTES, __alignof__(mbstate_t)), n * sizeof(FILE) + sizeof(*g)); Using __alignof__() involves 2 or 3 layers of style bugs: - it is a gnu-ish spelling (full gnu would also have a space before the left parentheses). The FreeBSD spelling is __alignof(). FreeBSD defines a macro for this, but only for compatiblity with gcc < 2.95. Later versions apparently support both __alignof and __alignof__() - C++ apparently spells this as both _Alignof() and alignof() after 2011/03 - FreeBSD defines _Alignof() unconditionally. The only difference for C++ after 2011/03 is it is less careful about namespaces and depends on alignof() existing and being part of the language. The general definition using __alignof() should work in this case too. So it seems that the correct spelling is _Alignof(). _Alignof(), __alignof() and __alignof__() are all in the implementation namespace except possibly _Alignof() for C++ after 2011/03, so any use of them gives undefined behaviour which might be to do the right thing. But no one knows what that is or when it is done since none of this is documented in a man page. sys/cdefs.h is now about 8.5 times as large and more than that many times as complicated and ugly as an FreeBSD-1 where it only had __P(()) and a few other portability macros to hide the differences between K&R and C90. It should be 8.5 times smaller (11 lines). It contains a mixture of old and new portability macros and perhaps some standard macros for newer C++ and C. I checked that it doesn't define anything without at least 1 leading underscore except for const, inline, signed and volatile in old compatibility modes. Bruce ___ 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: r292897 - head/sys/sparc64/include
Author: marius Date: Wed Dec 30 00:17:37 2015 New Revision: 292897 URL: https://svnweb.freebsd.org/changeset/base/292897 Log: Adapt CATR() to r283283. Modified: head/sys/sparc64/include/ktr.h Modified: head/sys/sparc64/include/ktr.h == --- head/sys/sparc64/include/ktr.h Wed Dec 30 00:04:57 2015 (r292896) +++ head/sys/sparc64/include/ktr.h Wed Dec 30 00:17:37 2015 (r292897) @@ -74,9 +74,9 @@ l2: add r2, 1, r3 ; \ * NB: this clobbers %y. */ #define CATR(mask, desc, r1, r2, r3, l1, l2, l3) \ - set mask, r1 ; \ - SET(ktr_mask, r3, r2) ; \ - lduw[r2], r2 ; \ + setxmask, r3, r1 ; \ + setxktr_mask, r3, r2 ; \ + ldx [r2], r2 ; \ and r2, r1, r1 ; \ brz r1, l3 ## f ; \ nop ; \ ___ 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: r292899 - head/sys/boot/forth
Author: dteske Date: Wed Dec 30 02:15:12 2015 New Revision: 292899 URL: https://svnweb.freebsd.org/changeset/base/292899 Log: Fix stack leak introduced by SVN r97201 (nextboot_conf support). Fix erroneous error path in error messages when processing boot_conf. Fixup stack comments for functions introduced by SVN r97201. Remove a questioning stack comment introduced by SVN r186789. NB: Comment removed because strdup usage here is correct/not a leak. MFC after:1 week Modified: head/sys/boot/forth/support.4th Modified: head/sys/boot/forth/support.4th == --- head/sys/boot/forth/support.4th Wed Dec 30 01:02:22 2015 (r292898) +++ head/sys/boot/forth/support.4th Wed Dec 30 02:15:12 2015 (r292899) @@ -833,7 +833,7 @@ get-current ( -- wid ) previous definiti repeat ; -: peek_file +: peek_file ( addr len -- ) 0 to end_of_file? reset_line_reading O_RDONLY fopen fd ! @@ -844,6 +844,7 @@ get-current ( -- wid ) previous definiti ['] process_assignment catch ['] free_buffers catch fd @ fclose + swap throw throw ; only forth also support-functions definitions @@ -1021,25 +1022,26 @@ string current_file_name_ref\ used to p ; : get_nextboot_conf_file ( -- addr len ) - nextboot_conf_file strget strdup \ XXX is the strdup a leak ? + nextboot_conf_file strget strdup ; : rewrite_nextboot_file ( -- ) get_nextboot_conf_file O_WRONLY fopen fd ! fd @ -1 = if EOPEN throw then - fd @ s' nextboot_enable="NO" ' fwrite + fd @ s' nextboot_enable="NO" ' fwrite ( fd buf len -- nwritten ) drop fd @ fclose ; -: include_nextboot_file +: include_nextboot_file ( -- ) get_nextboot_conf_file - ['] peek_file catch + ['] peek_file catch if 2drop then nextboot? if get_nextboot_conf_file +current_file_name_ref strref ['] load_conf catch process_conf_errors -['] rewrite_nextboot_file catch +['] rewrite_nextboot_file catch if 2drop then then ; ___ 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: r292900 - head/sys/powerpc/booke
Author: jhibbits Date: Wed Dec 30 02:23:14 2015 New Revision: 292900 URL: https://svnweb.freebsd.org/changeset/base/292900 Log: Rewrite tid_flush() in C. There's no need for it to be in asm. Also, by writing in C, and marking it static in pmap.c, it saves a branch to the function itself, as it's only used in one location. The generated asm is virtually identical to the handwritten code. Modified: head/sys/powerpc/booke/locore.S head/sys/powerpc/booke/pmap.c Modified: head/sys/powerpc/booke/locore.S == --- head/sys/powerpc/booke/locore.S Wed Dec 30 02:15:12 2015 (r292899) +++ head/sys/powerpc/booke/locore.S Wed Dec 30 02:23:14 2015 (r292900) @@ -658,77 +658,6 @@ __boot_page_padding: // /* - * void tid_flush(tlbtid_t tid); - * - * Invalidate all TLB0 entries which match the given TID. Note this is - * dedicated for cases when invalidation(s) should NOT be propagated to other - * CPUs. - * - * void tid_flush(tlbtid_t tid, int tlb0_ways, int tlb0_entries_per_way); - * - * XXX: why isn't this in C? - */ -ENTRY(tid_flush) - cmpwi %r3, TID_KERNEL - beq tid_flush_end /* don't evict kernel translations */ - - /* Disable interrupts */ - mfmsr %r10 - wrteei 0 - - li %r6, 0 /* ways counter */ -loop_ways: - li %r7, 0 /* entries [per way] counter */ -loop_entries: - /* Select TLB0 and ESEL (way) */ - lis %r8, MAS0_TLBSEL0@h - rlwimi %r8, %r6, 16, 14, 15 - mtspr SPR_MAS0, %r8 - isync - - /* Select EPN (entry within the way) */ - rlwinm %r8, %r7, 12, 13, 19 - mtspr SPR_MAS2, %r8 - isync - tlbre - - /* Check if valid entry */ - mfspr %r8, SPR_MAS1 - andis. %r9, %r8, MAS1_VALID@h - beq next_entry /* invalid entry */ - - /* Check if this is our TID */ - rlwinm %r9, %r8, 16, 24, 31 - - cmplw %r9, %r3 - bne next_entry /* not our TID */ - - /* Clear VALID bit */ - rlwinm %r8, %r8, 0, 1, 31 - mtspr SPR_MAS1, %r8 - isync - tlbwe - isync - msync - -next_entry: - addi%r7, %r7, 1 - cmpw%r7, %r5 - bne loop_entries - - /* Next way */ - addi%r6, %r6, 1 - cmpw%r6, %r4 - bne loop_ways - - /* Restore MSR (possibly re-enable interrupts) */ - mtmsr %r10 - isync - -tid_flush_end: - blr - -/* * Cache disable/enable/inval sequences according * to section 2.16 of E500CORE RM. */ Modified: head/sys/powerpc/booke/pmap.c == --- head/sys/powerpc/booke/pmap.c Wed Dec 30 02:15:12 2015 (r292899) +++ head/sys/powerpc/booke/pmap.c Wed Dec 30 02:23:14 2015 (r292900) @@ -161,7 +161,6 @@ unsigned int kernel_ptbls; /* Number of #define PMAP_REMOVE_DONE(pmap) \ ((pmap) != kernel_pmap && (pmap)->pm_stats.resident_count == 0) -extern void tid_flush(tlbtid_t tid, int tlb0_ways, int tlb0_entries_per_way); extern int elf32_nxstack; /**/ @@ -195,6 +194,7 @@ static unsigned int tlb1_idx; static vm_offset_t tlb1_map_base = VM_MAX_KERNEL_ADDRESS; static tlbtid_t tid_alloc(struct pmap *); +static void tid_flush(tlbtid_t tid); static void tlb_print_entry(int, uint32_t, uint32_t, uint32_t, uint32_t); @@ -2915,7 +2915,7 @@ tid_alloc(pmap_t pmap) tidbusy[thiscpu][tid]->pm_tid[thiscpu] = TID_NONE; /* Flush all entries from TLB0 matching this TID. */ - tid_flush(tid, tlb0_ways, tlb0_entries_per_way); + tid_flush(tid); } tidbusy[thiscpu][tid] = pmap; @@ -3426,3 +3426,48 @@ tlb1_iomapped(int i, vm_paddr_t pa, vm_s *va = (tlb1[i].mas2 & MAS2_EPN_MASK) + (pa - pa_start); return (0); } + +/* + * Invalidate all TLB0 entries which match the given TID. Note this is + * dedicated for cases when invalidations should NOT be propagated to other + * CPUs. + */ +static void +tid_flush(tlbtid_t tid) +{ + register_t msr; + uint32_t mas0, mas1, mas2; + int entry, way; + + + /* Don't evict kernel translations */ + if (tid == TID_KERNEL) + return; + + msr = mfmsr(); + __asm __volatile("wrteei 0"); + + for (way = 0; way < TLB0_WAYS; way++) + for (entry = 0; entry < TLB0_ENTRIES_PER_WAY; entry++) { + + mas0 = MAS0_TLBSEL(0) | MAS0_ESEL(way); + mtspr(SPR_MAS0, mas0); + __asm __volatile("isync"); + + mas2 = entry << MAS2_TLB0_ENTRY_IDX_SHIFT; + mtspr(SPR_MAS2, mas2);
svn commit: r292901 - head/sys/powerpc/booke
Author: jhibbits Date: Wed Dec 30 02:26:04 2015 New Revision: 292901 URL: https://svnweb.freebsd.org/changeset/base/292901 Log: Optimize zero_page for book-e mmu. Instead of indirectly calling bzero() through mmu_booke_zero_page_area, zero the full page the same way as the AIM pmap logic does: using dcbz. Modified: head/sys/powerpc/booke/pmap.c Modified: head/sys/powerpc/booke/pmap.c == --- head/sys/powerpc/booke/pmap.c Wed Dec 30 02:23:14 2015 (r292900) +++ head/sys/powerpc/booke/pmap.c Wed Dec 30 02:26:04 2015 (r292901) @@ -2235,8 +2235,17 @@ mmu_booke_zero_page_area(mmu_t mmu, vm_p static void mmu_booke_zero_page(mmu_t mmu, vm_page_t m) { + vm_offset_t off, va; - mmu_booke_zero_page_area(mmu, m, 0, PAGE_SIZE); + mtx_lock(&zero_page_mutex); + va = zero_page_va; + + mmu_booke_kenter(mmu, va, VM_PAGE_TO_PHYS(m)); + for (off = 0; off < PAGE_SIZE; off += cacheline_size) + __asm __volatile("dcbzl 0,%0" :: "r"(va + off)); + mmu_booke_kremove(mmu, va); + + mtx_unlock(&zero_page_mutex); } /* ___ 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: r292902 - head/lib/libc/stdio
Author: imp Date: Wed Dec 30 03:36:22 2015 New Revision: 292902 URL: https://svnweb.freebsd.org/changeset/base/292902 Log: Use __alignof__ instead of assuming int64_t to get the right alignment. Differential Revision: https://reviews.freebsd.org/D4708 Modified: head/lib/libc/stdio/findfp.c Modified: head/lib/libc/stdio/findfp.c == --- head/lib/libc/stdio/findfp.cWed Dec 30 02:26:04 2015 (r292901) +++ head/lib/libc/stdio/findfp.cWed Dec 30 03:36:22 2015 (r292902) @@ -99,16 +99,7 @@ moreglue(int n) FILE *p; size_t align; - /* -* FILE has a mbstate_t variable. This variable tries to be int64_t -* aligned through its definition. int64_t may be larger than void *, -* which is the size traditionally used for ALIGNBYTES. So, use our own -* rounding instead of the MI ALIGN macros. If for some reason -* ALIGNBYTES is larger than int64_t, respect that too. There appears to -* be no portable way to ask for FILE's alignment requirements other -* than just knowing here. -*/ - align = MAX(ALIGNBYTES, sizeof(int64_t)); + align = __alignof__(FILE); g = (struct glue *)malloc(sizeof(*g) + align + n * sizeof(FILE)); if (g == NULL) return (NULL); ___ 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: r292903 - in head/sys/powerpc: booke mpc85xx
Author: jhibbits Date: Wed Dec 30 03:43:25 2015 New Revision: 292903 URL: https://svnweb.freebsd.org/changeset/base/292903 Log: Add platform support for QorIQ SoCs. This includes the following changes: * SMP kickoff for QorIQ (tested on P5020) * Errata fixes for some silicon revisions * Enables L2 (and L3 if available) caches Obtained from:Semihalf Sponsored by: Alex Perez/Inertial Computing Modified: head/sys/powerpc/booke/booke_machdep.c head/sys/powerpc/booke/locore.S head/sys/powerpc/booke/machdep_e500.c head/sys/powerpc/mpc85xx/mpc85xx.c head/sys/powerpc/mpc85xx/mpc85xx.h head/sys/powerpc/mpc85xx/platform_mpc85xx.c Modified: head/sys/powerpc/booke/booke_machdep.c == --- head/sys/powerpc/booke/booke_machdep.c Wed Dec 30 03:36:22 2015 (r292902) +++ head/sys/powerpc/booke/booke_machdep.c Wed Dec 30 03:43:25 2015 (r292903) @@ -316,8 +316,20 @@ booke_init(uint32_t arg1, uint32_t arg2) ret = powerpc_init(dtbp, 0, 0, mdp); - /* Enable L1 caches */ + /* Default to 32 byte cache line size. */ + switch ((mfpvr()) >> 16) { + case FSL_E500mc: + case FSL_E5500: + case FSL_E6500: + cacheline_size = 64; + break; + } + + /* Enable caches */ booke_enable_l1_cache(); + booke_enable_l2_cache(); + + booke_enable_bpred(); return (ret); } Modified: head/sys/powerpc/booke/locore.S == --- head/sys/powerpc/booke/locore.S Wed Dec 30 03:36:22 2015 (r292902) +++ head/sys/powerpc/booke/locore.S Wed Dec 30 03:43:25 2015 (r292903) @@ -301,7 +301,7 @@ bp_ntlb1s: .globl bp_tlb1 bp_tlb1: - .space 4 * 3 * 16 + .space 4 * 3 * 64 .globl bp_tlb1_end bp_tlb1_end: @@ -731,6 +731,113 @@ ENTRY(icache_enable) blr /* + * L2 cache disable/enable/inval sequences for E500mc. + */ + +ENTRY(l2cache_inval) + mfspr %r3, SPR_L2CSR0 + oris%r3, %r3, (L2CSR0_L2FI | L2CSR0_L2LFC)@h + ori %r3, %r3, (L2CSR0_L2FI | L2CSR0_L2LFC)@l + isync + mtspr SPR_L2CSR0, %r3 + isync +1: mfspr %r3, SPR_L2CSR0 + andis. %r3, %r3, L2CSR0_L2FI@h + bne 1b + blr + +ENTRY(l2cache_enable) + mfspr %r3, SPR_L2CSR0 + oris%r3, %r3, (L2CSR0_L2E | L2CSR0_L2PE)@h + isync + mtspr SPR_L2CSR0, %r3 + isync + blr + +/* + * Branch predictor setup. + */ +ENTRY(bpred_enable) + mfspr %r3, SPR_BUCSR + ori %r3, %r3, BUCSR_BBFI + isync + mtspr SPR_BUCSR, %r3 + isync + ori %r3, %r3, BUCSR_BPEN + isync + mtspr SPR_BUCSR, %r3 + isync + blr + +ENTRY(dataloss_erratum_access) + /* Lock two cache lines into I-Cache */ + sync + mfspr %r11, SPR_L1CSR1 + rlwinm %r11, %r11, 0, ~L1CSR1_ICUL + sync + isync + mtspr SPR_L1CSR1, %r11 + isync + + mflr%r9 + bl 1f + .long 2f-. +1: + mflr%r5 + lwz %r8, 0(%r5) + mtlr%r9 + add %r8, %r8, %r5 + icbtls 0, 0, %r8 + addi%r9, %r8, 64 + + sync + mfspr %r11, SPR_L1CSR1 +3: andi. %r11, %r11, L1CSR1_ICUL + bne 3b + + icbtls 0, 0, %r9 + + sync + mfspr %r11, SPR_L1CSR1 +3: andi. %r11, %r11, L1CSR1_ICUL + bne 3b + + b 2f + .align 6 + /* Inside a locked cacheline, wait a while, write, then wait a while */ +2: sync + + mfspr %r5, TBR_TBL +4: addis %r11, %r5, 0x10@h /* wait around one million timebase ticks */ + mfspr %r5, TBR_TBL + subf. %r5, %r5, %r11 + bgt 4b + + stw %r4, 0(%r3) + + mfspr %r5, TBR_TBL +4: addis %r11, %r5, 0x10@h /* wait around one million timebase ticks */ + mfspr %r5, TBR_TBL + subf. %r5, %r5, %r11 + bgt 4b + + sync + + /* +* Fill out the rest of this cache line and the next with nops, +* to ensure that nothing outside the locked area will be +* fetched due to a branch. +*/ + .rept 19 + nop + .endr + + icblc 0, 0, %r8 + icblc 0, 0, %r9 + + blr + +/* * int setfault() * * Similar to setjmp to setup for handling faults on accesses to user memory. Modified: head/sys/powerpc/booke/machdep_e500.c == --- head/sys/powerpc/booke/machdep_e500.c Wed Dec 30 03:36:22 2015 (r292902) +++ head/sys/powerpc/booke/machdep_e500.c Wed Dec 30 03:43:25 2015 (r292903) @@ -27,9 +27,15 @@ #include __FBSDID("$FreeBSD$"); +#include #include +#include +#include #inclu
Re: svn commit: r292809 - head/lib/libc/stdio
On 30 Dec 2015, at 00:48, Bruce Evans wrote: > > - C++ apparently spells this as both _Alignof() and alignof() after 2011/03 This is not correct. C++ spells it alignof. C spells it _Alignof, unless you include , in which case C spells it alignof and defines _ _alignof_is_defined. On FreeBSD, we define _Alignof in C++ mode, because it’s in the reserved identifier space and gives us something that works in C and C++. David ___ 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: r292809 - head/lib/libc/stdio
On Wed, 30 Dec 2015, David Chisnall wrote: On 30 Dec 2015, at 00:48, Bruce Evans wrote: - C++ apparently spells this as both _Alignof() and alignof() after 2011/03 This is not correct. C++ spells it alignof. C spells it _Alignof, unless you include , in which case C spells it alignof and defines _ _alignof_is_defined. On FreeBSD, we define _Alignof in C++ mode, because it???s in the reserved identifier space and gives us something that works in C and C++. So it is more broken than first appeared :-). Extra spellings are a bug since users don't know which one to use and prefer the worst one unless they are experts in at least 3 versions of 3 standards (C-K&R, C90, C99, C11, C++-mumble, gnu89, gnu99, gnu11) and FreeBSD variations on these. There are also syntactical problems. stdalign.h uses _Alignas and _Alignof, but FreeBSD only defines _Alignas(x) and _Alignof(x). The former is because alignof is like sizeof so it doesn't need parentheses. However, alignof(typename) needs the parentheses and 'alignof expression' is apparently only a gnu extension, so it is difficult to construct an example of Standard code without the parentheses. _Alignas is more broken than _Alignof. In the C case, _Alignas(x) is as __aligned(x), but this only works if x is an expression. __aligned(x) is often used in FreeBSD code, but the same code in C++ with __aligned(x) replaced by alignas(x) with any spelling is a syntax error. Bruce___ 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: r292861 - head/sys/dev/hyperv/vmbus
Author: delphij Date: Tue Dec 29 08:19:43 2015 New Revision: 292861 URL: https://svnweb.freebsd.org/changeset/base/292861 Log: hyperv: vmbus: run non-blocking message handlers in vmbus_msg_swintr() We'll remove the per-channel control_work_queue because it can't properly do serialization of message handling, e.g., when there are 2 NIC devices, vmbus_channel_on_offer() -> hv_queue_work_item() has a race condition: for an SMP VM, vmbus_channel_process_offer() can run concurrently on different CPUs and if the second NIC's vmbus_channel_process_offer() -> hv_vmbus_child_device_register() runs first, the second NIC's name will be hn0 and the first NIC's name will be hn1! We can fix the race condition by removing the per-channel control_work_queue and run all the message handlers in the global hv_vmbus_g_connection.work_queue -- we'll do this in the next patch. With the coming next patch, we have to run the non-blocking handlers directly in the kernel thread vmbus_msg_swintr(), because the special handling of sub-channel: when a sub-channel (e.g., of the storvsc driver) is received and being handled in vmbus_channel_on_offer() running on the global hv_vmbus_g_connection.work_queue, vmbus_channel_process_offer() invokes channel->sc_creation_callback, i.e., storvsc_handle_sc_creation, and the callback will invoke hv_vmbus_channel_open() -> hv_vmbus_post_message and expect a further reply from the host, but the handling of the further messag can't be done because the current message's handling hasn't finished yet; as result, hv_vmbus_channel_open() -> sema_timedwait() will time out and th device can't work. Also renamed the handler type from hv_pfn_channel_msg_handler to vmbus_msg_handler: the 'pfn' and 'channel' in the old name make no sense. Submitted by: Dexuan Cui Reviewed by: royger MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D4596 Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c == --- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Dec 29 08:19:06 2015 (r292860) +++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Dec 29 08:19:43 2015 (r292861) @@ -31,13 +31,6 @@ #include "hv_vmbus_priv.h" -typedef void (*hv_pfn_channel_msg_handler)(hv_vmbus_channel_msg_header* msg); - -typedef struct hv_vmbus_channel_msg_table_entry { - hv_vmbus_channel_msg_typemessageType; - hv_pfn_channel_msg_handler messageHandler; -} hv_vmbus_channel_msg_table_entry; - /* * Internal functions */ @@ -55,29 +48,40 @@ static void vmbus_channel_on_version_res */ hv_vmbus_channel_msg_table_entry g_channel_message_table[HV_CHANNEL_MESSAGE_COUNT] = { - { HV_CHANNEL_MESSAGE_INVALID, NULL }, - { HV_CHANNEL_MESSAGE_OFFER_CHANNEL, vmbus_channel_on_offer }, + { HV_CHANNEL_MESSAGE_INVALID, + 0, NULL }, + { HV_CHANNEL_MESSAGE_OFFER_CHANNEL, + 0, vmbus_channel_on_offer }, { HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER, - vmbus_channel_on_offer_rescind }, - { HV_CHANNEL_MESSAGE_REQUEST_OFFERS, NULL }, + 0, vmbus_channel_on_offer_rescind }, + { HV_CHANNEL_MESSAGE_REQUEST_OFFERS, + 0, NULL }, { HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED, - vmbus_channel_on_offers_delivered }, - { HV_CHANNEL_MESSAGE_OPEN_CHANNEL, NULL }, + 1, vmbus_channel_on_offers_delivered }, + { HV_CHANNEL_MESSAGE_OPEN_CHANNEL, + 0, NULL }, { HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT, - vmbus_channel_on_open_result }, - { HV_CHANNEL_MESSAGE_CLOSE_CHANNEL, NULL }, - { HV_CHANNEL_MESSAGEL_GPADL_HEADER, NULL }, - { HV_CHANNEL_MESSAGE_GPADL_BODY, NULL }, + 1, vmbus_channel_on_open_result }, + { HV_CHANNEL_MESSAGE_CLOSE_CHANNEL, + 0, NULL }, + { HV_CHANNEL_MESSAGEL_GPADL_HEADER, + 0, NULL }, + { HV_CHANNEL_MESSAGE_GPADL_BODY, + 0, NULL }, { HV_CHANNEL_MESSAGE_GPADL_CREATED, - vmbus_channel_on_gpadl_created }, - { HV_CHANNEL_MESSAGE_GPADL_TEARDOWN, NULL }, + 1, vmbus_channel_on_gpadl_created }, + { HV_CHANNEL_MESSAGE_GPADL_TEARDOWN, + 0, NULL }, { HV_CHANNEL_MESSAGE_GPADL_TORNDOWN, - vmbus_channel_on_gpadl_torndown }, - { HV_CHANNEL_MESSAGE_REL_ID_RELEASED, NULL }, - { HV_CHANNEL_MESSAGE_INITIATED_CONTACT, NULL }, + 1, vmbus_channel_on_gpadl_torndown }, + { HV_CHANNEL_MESSAGE_REL_ID_RELEASED, + 0, NULL }, + { HV_CHANNEL_MESSAGE_INITIATED_CONTACT, + 0, NULL }, { HV_CHANNEL
svn commit: r292863 - in head/sbin: mount umount
Author: uqs Date: Tue Dec 29 11:24:35 2015 New Revision: 292863 URL: https://svnweb.freebsd.org/changeset/base/292863 Log: Fix type mismatches for malloc(3) and Co. Found by: clang static analyzer Reviewed by: ed Differential Revision:https://reviews.freebsd.org/D4722 Modified: head/sbin/mount/mount.c head/sbin/umount/umount.c Modified: head/sbin/mount/mount.c == --- head/sbin/mount/mount.c Tue Dec 29 08:39:07 2015(r292862) +++ head/sbin/mount/mount.c Tue Dec 29 11:24:35 2015(r292863) @@ -541,7 +541,7 @@ append_arg(struct cpa *sa, char *arg) { if (sa->c + 1 == sa->sz) { sa->sz = sa->sz == 0 ? 8 : sa->sz * 2; - sa->a = realloc(sa->a, sizeof(sa->a) * sa->sz); + sa->a = realloc(sa->a, sizeof(*sa->a) * sa->sz); if (sa->a == NULL) errx(1, "realloc failed"); } Modified: head/sbin/umount/umount.c == --- head/sbin/umount/umount.c Tue Dec 29 08:39:07 2015(r292862) +++ head/sbin/umount/umount.c Tue Dec 29 11:24:35 2015(r292863) @@ -434,7 +434,7 @@ getmntentry(const char *fromname, const { static struct statfs *mntbuf; static size_t mntsize = 0; - static char *mntcheck = NULL; + static int *mntcheck = NULL; struct statfs *sfs, *foundsfs; int i, count; ___ 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: r292864 - in head: usr.bin/column usr.bin/locate/locate usr.bin/xargs usr.sbin/mountd usr.sbin/mpsutil usr.sbin/rpc.lockd usr.sbin/rpc.statd usr.sbin/rtsold
Author: uqs Date: Tue Dec 29 11:24:41 2015 New Revision: 292864 URL: https://svnweb.freebsd.org/changeset/base/292864 Log: Fix type mismatches for malloc(3) and Co. This is rather pedantic, as for most architectures it holds that sizeof(type *) == sizeof(type **) Found by: clang static analyzer Reviewed by: ed Differential Revision: https://reviews.freebsd.org/D4722 Modified: head/usr.bin/column/column.c head/usr.bin/locate/locate/util.c head/usr.bin/xargs/xargs.c head/usr.sbin/mountd/mountd.c head/usr.sbin/mpsutil/mps_cmd.c head/usr.sbin/rpc.lockd/lockd.c head/usr.sbin/rpc.statd/statd.c head/usr.sbin/rtsold/rtsold.c Modified: head/usr.bin/column/column.c == --- head/usr.bin/column/column.cTue Dec 29 11:24:35 2015 (r292863) +++ head/usr.bin/column/column.cTue Dec 29 11:24:41 2015 (r292864) @@ -244,7 +244,7 @@ maketbl(void) p = NULL) if (++coloff == maxcols) { if (!(cols = realloc(cols, ((u_int)maxcols + - DEFCOLS) * sizeof(char *))) || + DEFCOLS) * sizeof(wchar_t *))) || !(lens = realloc(lens, ((u_int)maxcols + DEFCOLS) * sizeof(int err(1, NULL); Modified: head/usr.bin/locate/locate/util.c == --- head/usr.bin/locate/locate/util.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.bin/locate/locate/util.c Tue Dec 29 11:24:41 2015 (r292864) @@ -93,7 +93,7 @@ colon(dbv, path, dot) char **pv; if (dbv == NULL) { - if ((dbv = malloc(sizeof(char **))) == NULL) + if ((dbv = malloc(sizeof(char *))) == NULL) err(1, "malloc"); *dbv = NULL; } @@ -123,7 +123,7 @@ colon(dbv, path, dot) *(p + slen) = '\0'; } /* increase dbv with element p */ - if ((dbv = realloc(dbv, sizeof(char **) * (vlen + 2))) + if ((dbv = realloc(dbv, sizeof(char *) * (vlen + 2))) == NULL) err(1, "realloc"); *(dbv + vlen) = p; Modified: head/usr.bin/xargs/xargs.c == --- head/usr.bin/xargs/xargs.c Tue Dec 29 11:24:35 2015(r292863) +++ head/usr.bin/xargs/xargs.c Tue Dec 29 11:24:41 2015(r292864) @@ -234,7 +234,7 @@ main(int argc, char *argv[]) * NULL. */ linelen = 1 + argc + nargs + 1; - if ((av = bxp = malloc(linelen * sizeof(char **))) == NULL) + if ((av = bxp = malloc(linelen * sizeof(char *))) == NULL) errx(1, "malloc failed"); /* @@ -471,7 +471,7 @@ prerun(int argc, char *argv[]) * Allocate memory to hold the argument list, and * a NULL at the tail. */ - tmp = malloc((argc + 1) * sizeof(char**)); + tmp = malloc((argc + 1) * sizeof(char *)); if (tmp == NULL) { warnx("malloc failed"); xexit(*argv, 1); Modified: head/usr.sbin/mountd/mountd.c == --- head/usr.sbin/mountd/mountd.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.sbin/mountd/mountd.c Tue Dec 29 11:24:41 2015 (r292864) @@ -422,7 +422,7 @@ main(int argc, char **argv) * list. */ if (nhosts == 0) { - hosts = malloc(sizeof(char**)); + hosts = malloc(sizeof(char *)); if (hosts == NULL) out_of_mem(); hosts[0] = "*"; Modified: head/usr.sbin/mpsutil/mps_cmd.c == --- head/usr.sbin/mpsutil/mps_cmd.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.sbin/mpsutil/mps_cmd.c Tue Dec 29 11:24:41 2015 (r292864) @@ -486,7 +486,7 @@ mps_firmware_get(int fd, unsigned char * } size = reply.ActualImageSize; - *firmware = calloc(1, sizeof(char) * size); + *firmware = calloc(1, sizeof(unsigned char) * size); if (*firmware == NULL) { warn("calloc"); return (-1); Modified: head/usr.sbin/rpc.lockd/lockd.c == --- head/usr.sbin/rpc.lockd/lockd.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.sbin/rpc.lockd/lockd.c Tue Dec 29 11:24:41 2015 (r292864) @@ -220,7 +220,7 @@ main(int argc, char **argv) * list.
svn commit: r292865 - head/sys/dev/usb
Author: hselasky Date: Tue Dec 29 11:53:13 2015 New Revision: 292865 URL: https://svnweb.freebsd.org/changeset/base/292865 Log: Update metadata for "tools/tools/bus_autoconf" after r292080. Use BYTE_ORDER instead of _BYTE_ORDER due to 3rd party USB software for now. Modified: head/sys/dev/usb/usb_lookup.c head/sys/dev/usb/usbdi.h Modified: head/sys/dev/usb/usb_lookup.c == --- head/sys/dev/usb/usb_lookup.c Tue Dec 29 11:24:41 2015 (r292864) +++ head/sys/dev/usb/usb_lookup.c Tue Dec 29 11:53:13 2015 (r292865) @@ -154,28 +154,10 @@ usbd_lookup_id_by_uaa(const struct usb_d /** * Export the USB device ID format we use to userspace tools. **/ -#if BYTE_ORDER == BIG_ENDIAN -#defineU16_XOR "8" -#defineU32_XOR "12" -#defineU64_XOR "56" -#defineU8_BITFIELD_XOR "7" -#defineU16_BITFIELD_XOR "15" -#defineU32_BITFIELD_XOR "31" -#defineU64_BITFIELD_XOR "63" -#else +#if BYTE_ORDER == LITTLE_ENDIAN #defineU16_XOR "0" -#defineU32_XOR "0" -#defineU64_XOR "0" -#defineU8_BITFIELD_XOR "0" -#defineU16_BITFIELD_XOR "0" -#defineU32_BITFIELD_XOR "0" -#defineU64_BITFIELD_XOR "0" -#endif - -#if USB_HAVE_COMPAT_LINUX -#defineMFL_SIZE "1" #else -#defineMFL_SIZE "0" +#defineU16_XOR "8" #endif #if defined(KLD_MODULE) && (USB_HAVE_ID_SECTION != 0) @@ -189,20 +171,19 @@ static const char __section("bus_autocon /* List size of fields in the usb_device_id structure */ -#if ULONG_MAX >= 0xUL - "unused{0,8}" - "unused{0,8}" - "unused{0,8}" - "unused{0,8}" -#if ULONG_MAX >= 0xULL - "unused{0,8}" - "unused{0,8}" - "unused{0,8}" - "unused{0,8}" -#endif -#else -#error "Please update code." -#endif + "mf_vendor{" U16_XOR ",1}" + "mf_product{" U16_XOR ",1}" + "mf_dev_lo{" U16_XOR ",1}" + "mf_dev_hi{" U16_XOR ",1}" + + "mf_dev_class{" U16_XOR ",1}" + "mf_dev_subclass{" U16_XOR ",1}" + "mf_dev_protocol{" U16_XOR ",1}" + "mf_int_class{" U16_XOR ",1}" + + "mf_int_subclass{" U16_XOR ",1}" + "mf_int_protocol{" U16_XOR ",1}" + "unused{" U16_XOR ",6}" "idVendor[0]{" U16_XOR ",8}" "idVendor[1]{" U16_XOR ",8}" @@ -220,38 +201,20 @@ static const char __section("bus_autocon "bInterfaceSubClass{0,8}" "bInterfaceProtocol{0,8}" - "mf_vendor{" U8_BITFIELD_XOR ",1}" - "mf_product{" U8_BITFIELD_XOR ",1}" - "mf_dev_lo{" U8_BITFIELD_XOR ",1}" - "mf_dev_hi{" U8_BITFIELD_XOR ",1}" - - "mf_dev_class{" U8_BITFIELD_XOR ",1}" - "mf_dev_subclass{" U8_BITFIELD_XOR ",1}" - "mf_dev_protocol{" U8_BITFIELD_XOR ",1}" - "mf_int_class{" U8_BITFIELD_XOR ",1}" - - "mf_int_subclass{" U8_BITFIELD_XOR ",1}" - "mf_int_protocol{" U8_BITFIELD_XOR ",1}" - "unused{" U8_BITFIELD_XOR ",6}" - - "mfl_vendor{" U16_XOR "," MFL_SIZE "}" - "mfl_product{" U16_XOR "," MFL_SIZE "}" - "mfl_dev_lo{" U16_XOR "," MFL_SIZE "}" - "mfl_dev_hi{" U16_XOR "," MFL_SIZE "}" - - "mfl_dev_class{" U16_XOR "," MFL_SIZE "}" - "mfl_dev_subclass{" U16_XOR "," MFL_SIZE "}" - "mfl_dev_protocol{" U16_XOR "," MFL_SIZE "}" - "mfl_int_class{" U16_XOR "," MFL_SIZE "}" - - "mfl_int_subclass{" U16_XOR "," MFL_SIZE "}" - "mfl_int_protocol{" U16_XOR "," MFL_SIZE "}" - "unused{" U16_XOR "," MFL_SIZE "}" - "unused{" U16_XOR "," MFL_SIZE "}" - - "unused{" U16_XOR "," MFL_SIZE "}" - "unused{" U16_XOR "," MFL_SIZE "}" - "unused{" U16_XOR "," MFL_SIZE "}" - "unused{" U16_XOR "," MFL_SIZE "}" +#if USB_HAVE_COMPAT_LINUX + "mfl_vendor{" U16_XOR ",1}" + "mfl_product{" U16_XOR ",1}" + "mfl_dev_lo{" U16_XOR ",1}" + "mfl_dev_hi{" U16_XOR ",1}" + + "mfl_dev_class{" U16_XOR ",1}" + "mfl_dev_subclass{" U16_XOR ",1}" + "mfl_dev_protocol{" U16_XOR ",1}" + "mfl_int_class{" U16_XOR ",1}" + + "mfl_int_subclass{" U16_XOR ",1}" + "mfl_int_protocol{" U16_XOR ",1}" + "unused{" U16_XOR ",6}" +#endif }; #endif Modified: head/sys/dev/usb/usbdi.h == --- head/sys/dev/usb/usbdi.hTue Dec 29 11:24:41 2015(r292864) +++ head/sys/dev/usb/usbdi.hTue Dec 29 11:53:13 2015(r292865) @@ -267,7 +267,7 @@ struct usb_config { struct usb_device_id { /* Select which fields to match against */ -#if _BYTE_ORDER == _LITTLE_ENDIAN +#if BYTE_ORDER == LITTLE_ENDIAN uint16_t match_flag_vendor:1, match_flag_product:1, @@ -315,
Re: svn commit: r292626 - head/sys/kern
On Tue, Dec 22, 2015 at 02:29:36PM -0800, NGie Cooper wrote: > > > On Dec 22, 2015, at 13:17, John Baldwin wrote: > > > > On Tuesday, December 22, 2015 09:07:33 PM Garrett Cooper wrote: > > … > > > It shouldn't be zero, I think == 1 would be best actually. > > I’ll boot up GENERIC and see whether or not it works with == 1. > Thanks :)! Any value other than in 1 is a bug. The value of 0 means the destination is not used, although it clearly is. Since the counter is signed, sufficiently big amount of users can actually make it negative, although that's an unrealistic for now. TL;DR please change it to equality check against 1. -- 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"
Re: svn commit: r292777 - in head: lib/libc/sys sys/kern
2015-12-28 1:35 GMT+03:00 Bruce Evans : > On Sun, 27 Dec 2015, Ian Lepore wrote: > > On Sun, 2015-12-27 at 15:37 +, Dmitry Chagin wrote: >> >>> Author: dchagin >>> Date: Sun Dec 27 15:37:07 2015 >>> New Revision: 292777 >>> URL: https://svnweb.freebsd.org/changeset/base/292777 >>> >>> Log: >>> Verify that tv_sec value specified in settimeofday() and >>> clock_settime() >>> (CLOCK_REALTIME case) system calls is non negative. >>> This commit hides a kernel panic in atrtc_settime() as the >>> clock_ts_to_ct() >>> does not properly convert negative tv_sec. >>> >>> ps. in my opinion clock_ts_to_ct() should be rewritten to properly >>> handle >>> negative tv_sec values. >>> >>> Differential Revision:https://reviews.freebsd.org/D4714 >>> Reviewed by: kib >>> >>> MFC after:1 week >>> >> >> IMO, this change is completely unacceptable. If there is a bug in >> atrtc code, then by all means fix it, but preventing anyone from >> setting valid time values on the system because one driver's code can't >> handle it is just wrong. >> > > I agree. Even (time_t)-1 should be a valid time for input, although it > is an error indicator for output. > (This API makes correctly using functions like time(1) difficult or > impossible (impossible for time(1) specifically. The implementation > might reserve (time_t)-1 for representing an invalid time. But > nothing requires it to. > (POSIX almost requires the reverse. It requires a broken > implementation that represents times as seconds since the Epoch. I > think POSIX doesn't require times before the Epoch to work. But > FreeBSD and the ado time package tries to make them work.) > So if the representation of the current time is (time_t)-1, then > time(1) can't do anything better than return this value. But this > value is also the error value. There is no way to distinguish this > value from the error value, since time(1) is not required to set > errno.) > > So, my point was: a) for a long time we have broken settimeofday() which does not allow us to set the system time before the Epoch b) as you already mentioned POSIX doesn't require times before the Epoch to work с) Linux does not allows negative seconds also d) we have settimeofsay(2) that consistent with POSIX and in my understanding phrase "The time is expressed in seconds and microseconds since midnight (0 hour), January 1, 1970." is a strict definition, which prohibits time before the Epoch I do not understand why we should have our own (separate from the rest world) behavior. > I think the change also doesn't actually work, especially in the Western > hemisphere, but it was written in the Eastern hemisphere. Suppose > that the time is the Epoch. This is 0, so it is pefectly valid. Then > if the clock is on local time, utc_offset() is added before calling > clock_cs_to_ct() and the result is a negative time_t in the Western > hemisphere. Similarly in the Eastern hemisphere when you test with > with Western settings. > > The main bug in clock_ts_ct() is due to division being specified as > broken in C: > > X void > X clock_ts_to_ct(struct timespec *ts, struct clocktime *ct) > X { > X int i, year, days; > X time_t rsec;/* remainder seconds */ > X time_t secs; > X X secs = ts->tv_sec; > X days = secs / SECDAY; > X rsec = secs % SECDAY; > > Division of negative numbers used to be implementation-defined in C, but > C90 or C99 broke this by requiring the broken alternative of rounding > towards 0 like most hardware does. The remainder operation is consistently > broken. So when secs < 0, this always gives days < 0 and rsec either 0 > or < 0. > > If this causes a panic, then it is from a sanity check detecting the > invalid conversion later. A negative value in days breaks the loop > logic but seems to give premature exit from the loops instead of many > iterations. > > Another bug here is the type of rsec. This variable is a small integer > (< SECDAY = 86400), not a time_t. > > Code like this is probably common in userland. w(1) uses it, but w(1) > only deals with uptimes which should be positive. > > clock_ct_to_ts() is also buggy: > > X int > X clock_ct_to_ts(struct clocktime *ct, struct timespec *ts) > X { > X int i, year, days; > X ... > X /* Sanity checks. */ > X if (ct->mon < 1 || ct->mon > 12 || ct->day < 1 || > X ct->day > days_in_month(year, ct->mon) || > X ct->hour > 23 || ct->min > 59 || ct->sec > 59 || > X (sizeof(time_t) == 4 && year > 2037)) { /* time_t overflow > */ > X if (ct_debug) > X printf(" = EINVAL\n"); > X return (EINVAL); > X } > > The limit of 2037 is bogus with 64-bit time_t's or even with 32-bit > unsigned time_t's. > > Years before 1970 are insane due to the C bug, and years before ~1906 > are insanse due to representability problems, but there is no check >
Re: svn commit: r292777 - in head: lib/libc/sys sys/kern
On Tue, 29 Dec 2015, Dmitry Chagin wrote: So, my point was: a) for a long time we have broken settimeofday() which does not allow us to set the system time before the Epoch We still have a broken settimeofday that doesn't allow us to set the system time to the Epoch in the Western hemisphere if the clock is on local time, and doesn't allow as to set the system time to a year > . More precisely it does allow us to set these and usually panics on x86 before completing. b) as you already mentioned POSIX doesn't require times before the Epoch to work In fact, the representation of times is undefined for times before the Epoch in general. The specification of clock_settime() is interesting. At least in an old POSIX-2001 draft, It is required to set to the specified time and is not limited to the current time, whatever that is. It is only required to work for CLOCK_REALTIME. It is required to fail if the specified time is outside of the "legal range" for the clock id. "legal range" is bad wording and is unspecified. ??) Linux does not allows negative seconds also Old (~2004) versions of Linux seem to have less error checking for i386 settimeofday() FreeBSD then, so they seem to allow it. The implementation seems to be: - copy the requested value to the kernel software time without much error checking. Don't touch the hardware yet - update the RTC every 11 minutes if the clock is externally synchronized. So with 64-bit time_t anyone could easily set the time to year +-292g, or just to year +-10k. The AT RTC cannot represent this, and it is difficult to make it try since it is difficult to find external servers running that far off the current time. With 32-bit time_t the range is 1906-2037. Linux seems to have no range checking for the conversion to BCD, but it doesn't panic because the BCD macros are expressions. These macros of course don't work for arbitrary inputs. They just convert valid but unusual years to garbage. Before that, negative times are converted to garbage using a type pun: set_rtc_mmss(xtime.tv_sec) starts with a time_t, but the function takes an unsigned long. So 1 second before the Epoch becomes year +584g. The usual divisions by 60 are used to reduce the type-punned time. Since it is unsigned, these now give garbage in-range values. d) we have settimeofsay(2) that consistent with POSIX and in my understanding phrase "The time is expressed in seconds and microseconds since midnight (0 hour), January 1, 1970." is a strict definition, which prohibits time before the Epoch TImes before the Epoch give undefined behaviour, so they are allowed to work. They are even allowed to work better than times after the Epoch, since they can have any representation and are not require to be missing support for leap seconds. I do not understand why we should have our own (separate from the rest world) behavior. It would be good to not have such broken bounds checkng as the rest of the world. Updating the AT RTC synchronously in settimeofday() is already more significantly different than limiting the range of accepted times. One reason that Linux updates asynchronously is that a correct synchronous update (which FreeBSD doesn't do) requires waiting for a second or two. The asynchronous update gives the usual problems handling errors -- even if the interrupt handler detected representation errors, it wouldn't be able to return them to settimeofday(). So errors of a measly 292g years go unreported. Bruce___ 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: r292870 - head/contrib/binutils/bfd
Author: ian Date: Tue Dec 29 15:23:03 2015 New Revision: 292870 URL: https://svnweb.freebsd.org/changeset/base/292870 Log: Correct the code for sign-extending a 16 bit value. As near as I can tell this is effectively a no-op -- the addend term in MOVT/MOVW relocations always seems to be zero. But this is correct and the old code wasn't. Modified: head/contrib/binutils/bfd/elf32-arm.c Modified: head/contrib/binutils/bfd/elf32-arm.c == --- head/contrib/binutils/bfd/elf32-arm.c Tue Dec 29 12:38:04 2015 (r292869) +++ head/contrib/binutils/bfd/elf32-arm.c Tue Dec 29 15:23:03 2015 (r292870) @@ -5800,7 +5800,7 @@ elf32_arm_final_link_relocate (reloc_how if (globals->use_rel) { addend = ((insn >> 4) & 0xf000) | (insn & 0xfff); - signed_addend = (addend ^ 0x1) - 0x1; + signed_addend = (addend ^ 0x8000) - 0x8000; } value += signed_addend; ___ 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: r292871 - head/share/misc
Author: miwi (doc,ports committer) Date: Tue Dec 29 15:36:46 2015 New Revision: 292871 URL: https://svnweb.freebsd.org/changeset/base/292871 Log: - Add myself to ports-secteam Approved by: delphij (implicit) Modified: head/share/misc/organization.dot Modified: head/share/misc/organization.dot == --- head/share/misc/organization.dotTue Dec 29 15:23:03 2015 (r292870) +++ head/share/misc/organization.dotTue Dec 29 15:36:46 2015 (r292871) @@ -34,7 +34,7 @@ portmgr [label="Port Management Team\npo portmgrsecretary [label="Port Management Team Secretary\nportmgr-secret...@freebsd.org\nculot"] re [label="Primary Release Engineering Team\n...@freebsd.org\nkib, blackend, jpaetzel, hrs, kensmith"] secteam [label="Security Team\nsect...@freebsd.org\nsimon, qingli, delphij,\nremko, philip, stas, cperciva,\ncsjp, rwatson, miwi, bz"] -portssecteam [label="Ports Security Team\nports-sect...@freebsd.org\ndelphij, eadler, feld, jgh, rea, sbz, simon, swills, zi"] +portssecteam [label="Ports Security Team\nports-sect...@freebsd.org\ndelphij, eadler, feld, jgh, rea, sbz, simon, swills, zi, miwi"] secteamsecretary [label="Security Team Secretary\nsecteam-secret...@freebsd.org\nremko"] securityofficer [label="Security Officer Team\nsecurity-offi...@freebsd.org\ncperciva, simon, nectar"] srccommitters [label="Src Committers\nsrc-committ...@freebsd.org"] ___ 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: r292872 - head/sys/fs/ext2fs
Author: pfg Date: Tue Dec 29 15:51:52 2015 New Revision: 292872 URL: https://svnweb.freebsd.org/changeset/base/292872 Log: ext2: recognize ext4 INCOMPAT_RECOVER flag This is a flag specific for journalling in ext4. Add it to the list of ext4 features we ignore for read-only purposes. PR: 205668 MFC after:1 week Modified: head/sys/fs/ext2fs/ext2fs.h Modified: head/sys/fs/ext2fs/ext2fs.h == --- head/sys/fs/ext2fs/ext2fs.h Tue Dec 29 15:36:46 2015(r292871) +++ head/sys/fs/ext2fs/ext2fs.h Tue Dec 29 15:51:52 2015(r292872) @@ -187,6 +187,7 @@ struct csum { #defineEXT2F_INCOMPAT_COMP 0x0001 #defineEXT2F_INCOMPAT_FTYPE0x0002 +#defineEXT2F_INCOMPAT_RECOVER 0x0004 #defineEXT2F_INCOMPAT_META_BG 0x0010 #defineEXT2F_INCOMPAT_EXTENTS 0x0040 #defineEXT2F_INCOMPAT_64BIT0x0080 @@ -208,6 +209,7 @@ struct csum { * * We do not support these EXT4 features but they are irrelevant * for read-only support: + * - EXT2F_INCOMPAT_RECOVER * - EXT2F_INCOMPAT_FLEX_BG * - EXT2F_INCOMPAT_META_BG */ @@ -216,6 +218,7 @@ struct csum { EXT2F_ROCOMPAT_EXTRA_ISIZE) #defineEXT2F_INCOMPAT_SUPP EXT2F_INCOMPAT_FTYPE #defineEXT4F_RO_INCOMPAT_SUPP (EXT2F_INCOMPAT_EXTENTS | \ +EXT2F_INCOMPAT_RECOVER | \ EXT2F_INCOMPAT_FLEX_BG | \ EXT2F_INCOMPAT_META_BG ) ___ 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: r292873 - head/share/misc
Author: miwi (doc,ports committer) Date: Tue Dec 29 15:54:34 2015 New Revision: 292873 URL: https://svnweb.freebsd.org/changeset/base/292873 Log: - Sort ports-secteam Modified: head/share/misc/organization.dot Modified: head/share/misc/organization.dot == --- head/share/misc/organization.dotTue Dec 29 15:51:52 2015 (r292872) +++ head/share/misc/organization.dotTue Dec 29 15:54:34 2015 (r292873) @@ -34,7 +34,7 @@ portmgr [label="Port Management Team\npo portmgrsecretary [label="Port Management Team Secretary\nportmgr-secret...@freebsd.org\nculot"] re [label="Primary Release Engineering Team\n...@freebsd.org\nkib, blackend, jpaetzel, hrs, kensmith"] secteam [label="Security Team\nsect...@freebsd.org\nsimon, qingli, delphij,\nremko, philip, stas, cperciva,\ncsjp, rwatson, miwi, bz"] -portssecteam [label="Ports Security Team\nports-sect...@freebsd.org\ndelphij, eadler, feld, jgh, rea, sbz, simon, swills, zi, miwi"] +portssecteam [label="Ports Security Team\nports-sect...@freebsd.org\ndelphij, eadler, feld, jgh, miwi, rea, sbz, simon, swills, zi"] secteamsecretary [label="Security Team Secretary\nsecteam-secret...@freebsd.org\nremko"] securityofficer [label="Security Officer Team\nsecurity-offi...@freebsd.org\ncperciva, simon, nectar"] srccommitters [label="Src Committers\nsrc-committ...@freebsd.org"] ___ 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: r292876 - head/usr.bin/dtc
Author: theraven Date: Tue Dec 29 16:29:42 2015 New Revision: 292876 URL: https://svnweb.freebsd.org/changeset/base/292876 Log: Improvements to BSD-licensed DTC. - Added an expression parser so that expressions from headers are now working - Fixed missing null terminators on cross references - Disabled exceptions / RTTI in the build for smaller binaries - Changed phandle order generation to be identical to GPL'd dtc Modified: head/usr.bin/dtc/Makefile head/usr.bin/dtc/checking.cc head/usr.bin/dtc/checking.hh head/usr.bin/dtc/dtb.hh head/usr.bin/dtc/fdt.cc head/usr.bin/dtc/fdt.hh head/usr.bin/dtc/input_buffer.cc head/usr.bin/dtc/input_buffer.hh Modified: head/usr.bin/dtc/Makefile == --- head/usr.bin/dtc/Makefile Tue Dec 29 16:11:43 2015(r292875) +++ head/usr.bin/dtc/Makefile Tue Dec 29 16:29:42 2015(r292876) @@ -6,7 +6,7 @@ MAN=dtc.1 WARNS?=3 -CXXFLAGS+= -std=c++11 +CXXFLAGS+= -std=c++11 -fno-rtti -fno-exceptions NO_SHARED?=NO Modified: head/usr.bin/dtc/checking.cc == --- head/usr.bin/dtc/checking.ccTue Dec 29 16:11:43 2015 (r292875) +++ head/usr.bin/dtc/checking.ccTue Dec 29 16:29:42 2015 (r292876) @@ -51,7 +51,7 @@ namespace struct address_cells_checker : public checker { address_cells_checker(const char *name) : checker(name) {} - virtual bool check_node(device_tree *tree, const node_ptr &n) + virtual bool check_node(device_tree *, const node_ptr &n) { // If this has no children, it trivially meets the // conditions. @@ -151,7 +151,7 @@ property_checker::check_property(device_ } bool -property_size_checker::check(device_tree *tree, const node_ptr &n, property_ptr p) +property_size_checker::check(device_tree *, const node_ptr &, property_ptr p) { uint32_t psize = 0; for (property::value_iterator i=p->begin(),e=p->end() ; i!=e ; ++i) Modified: head/usr.bin/dtc/checking.hh == --- head/usr.bin/dtc/checking.hhTue Dec 29 16:11:43 2015 (r292875) +++ head/usr.bin/dtc/checking.hhTue Dec 29 16:29:42 2015 (r292876) @@ -86,7 +86,7 @@ class checker * Method for checking that a node is valid. The root class version * does nothing, subclasses should override this. */ - virtual bool check_node(device_tree *tree, const node_ptr &n) + virtual bool check_node(device_tree *, const node_ptr &) { return true; } @@ -94,7 +94,7 @@ class checker * Method for checking that a property is valid. The root class * version does nothing, subclasses should override this. */ - virtual bool check_property(device_tree *tree, const node_ptr &n, property_ptr p) + virtual bool check_property(device_tree *, const node_ptr &, property_ptr ) { return true; } @@ -160,7 +160,7 @@ struct property_type_checker begin() == p->end(); } @@ -175,7 +175,7 @@ struct property_type_checker begin() + 1 == p->end()) && p->begin()->is_string(); } @@ -190,7 +190,7 @@ struct property_type_checker begin(),e=p->end() ; i!=e ; ++i) @@ -213,7 +213,7 @@ struct property_type_checker begin() + 1 == p->end()) && (tree->referenced_node(*p->begin()) != 0); Modified: head/usr.bin/dtc/dtb.hh == --- head/usr.bin/dtc/dtb.hh Tue Dec 29 16:11:43 2015(r292875) +++ head/usr.bin/dtc/dtb.hh Tue Dec 29 16:29:42 2015(r292876) @@ -186,11 +186,11 @@ class binary_writer : public output_writ * The binary format does not support labels, so this method * does nothing. */ - virtual void write_label(string name) {} + virtual void write_label(string) {} /** * Comments are ignored by the binary writer. */ - virtual void write_comment(string name) {} + virtual void write_comment(string) {} virtual void write_string(string name); virtual void write_data(uint8_t v); virtual void write_data(uint32_t v); Modified: head/usr.bin/dtc/fdt.cc == --- head/usr.bin/dtc/fdt.cc Tue Dec 29 16:11:43 2015(r292875) +++ head/usr.bin/dtc/fdt.cc Tue Dec 29 16:29:42 2015(r292876) @@ -264,24 +264,6 @@ property::parse_string(input_buffer &inp void property::parse_cells(input_buffer &input, int cell_size) { - unsigned long long cell_max; - switch (cell_size) - { - case 8:
svn commit: r292877 - head/bin/pax
Author: pfg Date: Tue Dec 29 16:31:28 2015 New Revision: 292877 URL: https://svnweb.freebsd.org/changeset/base/292877 Log: pax: prevent possible buffer overflow Or at least quiet down some static analyzers about it. CID: 978835 MFC after:1 week Obtained from:OpenBSD Modified: head/bin/pax/pat_rep.c Modified: head/bin/pax/pat_rep.c == --- head/bin/pax/pat_rep.c Tue Dec 29 16:29:42 2015(r292876) +++ head/bin/pax/pat_rep.c Tue Dec 29 16:31:28 2015(r292877) @@ -878,7 +878,7 @@ rep_name(char *name, int *nlen, int prnt * (the user already saw that substitution go by) */ pt = rephead; - (void)strcpy(buf1, name); + (void)strlcpy(buf1, name, sizeof(buf1)); inpt = buf1; outpt = nname; endpt = outpt + PAXPATHLEN; ___ 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: r292878 - head/sys/dev/puc
Author: marius Date: Tue Dec 29 17:07:28 2015 New Revision: 292878 URL: https://svnweb.freebsd.org/changeset/base/292878 Log: - Add entries for the more prominent members of the Digi International Neo series, which are based on Exar PCI chips. - Mark some unused parameters as such. - Fix style MFC after:3 days Modified: head/sys/dev/puc/pucdata.c Modified: head/sys/dev/puc/pucdata.c == --- head/sys/dev/puc/pucdata.c Tue Dec 29 16:31:28 2015(r292877) +++ head/sys/dev/puc/pucdata.c Tue Dec 29 17:07:28 2015(r292878) @@ -64,7 +64,6 @@ static puc_config_f puc_config_timedia; static puc_config_f puc_config_titan; const struct puc_cfg puc_pci_devices[] = { - { 0x0009, 0x7168, 0x, 0, "Sunix SUN1889", DEFAULT_RCLK * 8, @@ -179,6 +178,55 @@ const struct puc_cfg puc_pci_devices[] = .config_function = puc_config_amc }, + /* +* The following members of the Digi International Neo series are +* based on Exar PCI chips, f. e. the 8 port variants on XR17V258IV. +* Accordingly, the PCIe versions of these cards incorporate a PLX +* PCIe-PCI-bridge. +*/ + + { 0x114f, 0x00b0, 0x, 0, + "Digi Neo PCI 4 Port", + DEFAULT_RCLK * 8, + PUC_PORT_4S, 0x10, 0, -1, + .config_function = puc_config_exar + }, + + { 0x114f, 0x00b1, 0x, 0, + "Digi Neo PCI 8 Port", + DEFAULT_RCLK * 8, + PUC_PORT_8S, 0x10, 0, -1, + .config_function = puc_config_exar + }, + + { 0x114f, 0x00f0, 0x, 0, + "Digi Neo PCIe 8 Port", + DEFAULT_RCLK * 8, + PUC_PORT_8S, 0x10, 0, -1, + .config_function = puc_config_exar + }, + + { 0x114f, 0x00f1, 0x, 0, + "Digi Neo PCIe 4 Port", + DEFAULT_RCLK * 8, + PUC_PORT_4S, 0x10, 0, -1, + .config_function = puc_config_exar + }, + + { 0x114f, 0x00f2, 0x, 0, + "Digi Neo PCIe 4 Port RJ45", + DEFAULT_RCLK * 8, + PUC_PORT_4S, 0x10, 0, -1, + .config_function = puc_config_exar + }, + + { 0x114f, 0x00f3, 0x, 0, + "Digi Neo PCIe 8 Port RJ45", + DEFAULT_RCLK * 8, + PUC_PORT_8S, 0x10, 0, -1, + .config_function = puc_config_exar + }, + { 0x11fe, 0x8010, 0x, 0, "Comtrol RocketPort 550/8 RJ11 part A", DEFAULT_RCLK * 4, @@ -1208,9 +1256,10 @@ const struct puc_cfg puc_pci_devices[] = }; static int -puc_config_amc(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, +puc_config_amc(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd, int port, intptr_t *res) { + switch (cmd) { case PUC_CFG_GET_OFS: *res = 8 * (port & 1); @@ -1242,9 +1291,10 @@ puc_config_diva(struct puc_softc *sc, en } static int -puc_config_exar(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, -intptr_t *res) +puc_config_exar(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd, +int port, intptr_t *res) { + if (cmd == PUC_CFG_GET_OFS) { *res = port * 0x200; return (0); @@ -1253,9 +1303,10 @@ puc_config_exar(struct puc_softc *sc, en } static int -puc_config_exar_pcie(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, -intptr_t *res) +puc_config_exar_pcie(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd, +int port, intptr_t *res) { + if (cmd == PUC_CFG_GET_OFS) { *res = port * 0x400; return (0); @@ -1264,9 +1315,10 @@ puc_config_exar_pcie(struct puc_softc *s } static int -puc_config_icbook(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, -intptr_t *res) +puc_config_icbook(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd, +int port __unused, intptr_t *res) { + if (cmd == PUC_CFG_GET_ILR) { *res = PUC_ILR_DIGI; return (0); @@ -1278,9 +1330,9 @@ static int puc_config_moxa(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, intptr_t *res) { - if (cmd == PUC_CFG_GET_OFS) { - const struct puc_cfg *cfg = sc->sc_cfg; + const struct puc_cfg *cfg = sc->sc_cfg; + if (cmd == PUC_CFG_GET_OFS) { if (port == 3 && (cfg->device == 0x1045 || cfg->device == 0x1144)) port = 7; @@ -1292,8 +1344,8 @@ puc_config_moxa(struct puc_softc *sc, en } static int -puc_config_quatech(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, -intptr_t *res) +puc_config_quatech(struct puc_softc *sc, enum puc_cfg_cmd cmd, +int port __unused, intptr_t *res) { const struct puc_cfg *cfg = sc->sc_cfg; struct puc_bar *bar; @@ -1381,8 +1433,8 @@ puc_config_quatech(struct puc_softc
svn commit: r292881 - head/sys/netinet
Author: jtl Date: Tue Dec 29 19:20:39 2015 New Revision: 292881 URL: https://svnweb.freebsd.org/changeset/base/292881 Log: When checking the inp_ip_minttl restriction for IPv6 packets, don't check the IPv4 header. CID: 1017920 Differential Revision:https://reviews.freebsd.org/D4727 Reviewed by: bz MFC after:2 weeks Sponsored by: Juniper Networks Modified: head/sys/netinet/tcp_input.c Modified: head/sys/netinet/tcp_input.c == --- head/sys/netinet/tcp_input.cTue Dec 29 18:33:43 2015 (r292880) +++ head/sys/netinet/tcp_input.cTue Dec 29 19:20:39 2015 (r292881) @@ -919,9 +919,10 @@ findpcb: */ if (inp->inp_ip_minttl != 0) { #ifdef INET6 - if (isipv6 && inp->inp_ip_minttl > ip6->ip6_hlim) - goto dropunlock; - else + if (isipv6) { + if (inp->inp_ip_minttl > ip6->ip6_hlim) + goto dropunlock; + } else #endif if (inp->inp_ip_minttl > ip->ip_ttl) goto dropunlock; ___ 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: r292884 - head/usr.sbin/makefs
Author: ngie Date: Tue Dec 29 20:17:40 2015 New Revision: 292884 URL: https://svnweb.freebsd.org/changeset/base/292884 Log: Fix getopt(3) argument after r290180; I forgot to change -r to -R by accident MFC after: 3 days Pointyhat to: ngie Reported by: vangyzen Sponsored by: EMC / Isilon Storage Division Modified: head/usr.sbin/makefs/makefs.c Modified: head/usr.sbin/makefs/makefs.c == --- head/usr.sbin/makefs/makefs.c Tue Dec 29 19:56:26 2015 (r292883) +++ head/usr.sbin/makefs/makefs.c Tue Dec 29 20:17:40 2015 (r292884) @@ -116,7 +116,7 @@ main(int argc, char *argv[]) start_time.tv_sec = start.tv_sec; start_time.tv_nsec = start.tv_usec * 1000; - while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pr:s:S:t:xZ")) != -1) { + while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pR:s:S:t:xZ")) != -1) { switch (ch) { case 'B': ___ 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: r292887 - head/bin/sh
Author: jilles Date: Tue Dec 29 20:51:29 2015 New Revision: 292887 URL: https://svnweb.freebsd.org/changeset/base/292887 Log: sh: Split subevalvar() in #/##/%/%% and =/? parts. Modified: head/bin/sh/expand.c Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cTue Dec 29 20:42:42 2015(r292886) +++ head/bin/sh/expand.cTue Dec 29 20:51:29 2015(r292887) @@ -101,7 +101,8 @@ static char *argstr(char *, int); static char *exptilde(char *, int); static char *expari(char *); static void expbackq(union node *, int, int); -static int subevalvar(char *, char *, int, int, int, int, int); +static int subevalvar_trim(char *, int, int, int, int); +static int subevalvar_misc(char *, const char *, int, int, int); static char *evalvar(char *, int); static int varisset(const char *, int); static void strtodest(const char *, int, int, int); @@ -521,42 +522,23 @@ recordleft(const char *str, const char * } static int -subevalvar(char *p, char *str, int strloc, int subtype, int startloc, - int varflags, int quotes) +subevalvar_trim(char *p, int strloc, int subtype, int startloc, int quotes) { char *startp; char *loc = NULL; char *q; + char *str; int c = 0; struct nodelist *saveargbackq = argbackq; int amount; - argstr(p, (subtype == VSTRIMLEFT || subtype == VSTRIMLEFTMAX || - subtype == VSTRIMRIGHT || subtype == VSTRIMRIGHTMAX ? - EXP_CASE : 0) | EXP_TILDE); + argstr(p, EXP_CASE | EXP_TILDE); STACKSTRNUL(expdest); argbackq = saveargbackq; startp = stackblock() + startloc; - if (str == NULL) - str = stackblock() + strloc; + str = stackblock() + strloc; switch (subtype) { - case VSASSIGN: - setvar(str, startp, 0); - amount = startp - expdest; - STADJUST(amount, expdest); - varflags &= ~VSNUL; - return 1; - - case VSQUESTION: - if (*p != CTLENDVAR) { - outfmt(out2, "%s\n", startp); - error((char *)NULL); - } - error("%.*s: parameter %snot set", (int)(p - str - 1), - str, (varflags & VSNUL) ? "null or " : ""); - return 0; - case VSTRIMLEFT: for (loc = startp; loc < str; loc++) { c = *loc; @@ -630,6 +612,41 @@ subevalvar(char *p, char *str, int strlo } +static int +subevalvar_misc(char *p, const char *var, int subtype, int startloc, + int varflags) +{ + char *startp; + struct nodelist *saveargbackq = argbackq; + int amount; + + argstr(p, EXP_TILDE); + STACKSTRNUL(expdest); + argbackq = saveargbackq; + startp = stackblock() + startloc; + + switch (subtype) { + case VSASSIGN: + setvar(var, startp, 0); + amount = startp - expdest; + STADJUST(amount, expdest); + return 1; + + case VSQUESTION: + if (*p != CTLENDVAR) { + outfmt(out2, "%s\n", startp); + error((char *)NULL); + } + error("%.*s: parameter %snot set", (int)(p - var - 1), + var, (varflags & VSNUL) ? "null or " : ""); + return 0; + + default: + abort(); + } +} + + /* * Expand a variable, and return a pointer to the next character in the * input string. @@ -760,8 +777,8 @@ again: /* jump here after setting a vari */ STPUTC('\0', expdest); patloc = expdest - stackblock(); - if (subevalvar(p, NULL, patloc, subtype, - startloc, varflags, quotes) == 0) { + if (subevalvar_trim(p, patloc, subtype, + startloc, quotes) == 0) { int amount = (expdest - stackblock() - patloc) + 1; STADJUST(-amount, expdest); } @@ -773,8 +790,8 @@ again: /* jump here after setting a vari case VSASSIGN: case VSQUESTION: if (!set) { - if (subevalvar(p, var, 0, subtype, startloc, varflags, - quotes)) { + if (subevalvar_misc(p, var, subtype, startloc, + varflags)) { varflags &= ~VSNUL; /* * Remove any recorded regions beyond ___ 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: r292809 - head/lib/libc/stdio
On Monday, December 28, 2015 01:01:26 PM Warner Losh wrote: > I'll look at that, but I don't think posix_memalign is the right way to go. > The alignment of FILE is more strict than posix_memalign will return. Ian's > idea of __alignof__ is the way to go. We allocate them in one block on > purpose for performance, and posix_memalign would be a one at a time affair. posix_memalign gives you whatever alignment you ask for. Using __alignof__ to determine the alignment instead of hardcoding sizeof(int64_t) would certainly be an improvement. If you move the glue after the FILE objects then you can use posix_memalign() directly as so: void *mem; int error; error = posix_memalign(&mem, MAX(ALIGNBYTES, __alignof__(mbstate_t)), n * sizeof(FILE) + sizeof(*g)); if (error) return (NULL); p = (FILE *)mem; g = (struct glue *)(p + n); g->next = NULL; g->niobs = n; g->iobs = p; ... (This presumes that the requested alignment of 'struct glue' is less than the alignment needed by FILE which should be true.) -- John Baldwin ___ 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: r292772 - head/sys/vm
On Sun, Dec 27, 2015 at 02:42:39PM +, Konstantin Belousov wrote: K> Author: kib K> Date: Sun Dec 27 14:42:39 2015 K> New Revision: 292772 K> URL: https://svnweb.freebsd.org/changeset/base/292772 K> K> Log: K> Add missed relpbuf() for a smallfs page-in. K> K> Reported by: Shawn Webb K> Tested by: pho K> Sponsored by: The FreeBSD Foundation K> K> Modified: K> head/sys/vm/vnode_pager.c K> K> Modified: head/sys/vm/vnode_pager.c K> == K> --- head/sys/vm/vnode_pager.cSun Dec 27 14:39:47 2015 (r292771) K> +++ head/sys/vm/vnode_pager.cSun Dec 27 14:42:39 2015 (r292772) K> @@ -806,6 +806,7 @@ vnode_pager_generic_getpages(struct vnod K> * than a page size, then use special small filesystem code. K> */ K> if (pagesperblock == 0) { K> +relpbuf(bp, freecnt); K> for (i = 0; i < count; i++) { K> PCPU_INC(cnt.v_vnodein); K> PCPU_INC(cnt.v_vnodepgsin); The reason for this bug is that I tried to move the (pagesperblock == 0) block above the call to getpbuf(). We actually know that filesystem is "small" at the very beginning of the function and we can branch into "small filesystem" pager immediately. Later I moved the block back to its place, simply because new place wasn't tested properly. And forgot to restore relpbuf. What filesystem did you use to show up the bug? I'm about to test the variant with immediate branching. Shawn, would you be able to test a patch if I produce one? -- 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"
svn commit: r292888 - head/sys/boot/uboot/common
Author: ian Date: Tue Dec 29 21:29:05 2015 New Revision: 292888 URL: https://svnweb.freebsd.org/changeset/base/292888 Log: Fix the error checking for the ubenv command. This moves the check for an empty ldvar (which amounts to the varname string starting with '=') into the if block that manipulates ldvar, which avoids later referencing ldvar when it was never initialized. Submitted by: Thomas Skibo Pointy hat: ian Modified: head/sys/boot/uboot/common/main.c Modified: head/sys/boot/uboot/common/main.c == --- head/sys/boot/uboot/common/main.c Tue Dec 29 20:51:29 2015 (r292887) +++ head/sys/boot/uboot/common/main.c Tue Dec 29 21:29:05 2015 (r292888) @@ -585,6 +585,10 @@ handle_uboot_env_var(enum ubenv_action a */ if (action == UBENV_IMPORT) { len = strcspn(var, "="); + if (len == 0) { + printf("name cannot start with '=': '%s'\n", var); + return; + } if (var[len] == 0) { strcpy(ldvar, "uboot."); strncat(ldvar, var, sizeof(ldvar) - 7); @@ -604,9 +608,11 @@ handle_uboot_env_var(enum ubenv_action a var = &var[6]; } - /* If ldvar is malformed or there's no variable name left, punt. */ - if (ldvar[0] == 0 || var[0] == 0) + /* If there is no variable name left, punt. */ + if (var[0] == 0) { + printf("empty variable name\n"); return; + } val = ub_env_get(var); if (action == UBENV_SHOW) { ___ 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: r292772 - head/sys/vm
On Tuesday, December 29, 2015, Gleb Smirnoff wrote: > On Sun, Dec 27, 2015 at 02:42:39PM +, Konstantin Belousov wrote: > K> Author: kib > K> Date: Sun Dec 27 14:42:39 2015 > K> New Revision: 292772 > K> URL: https://svnweb.freebsd.org/changeset/base/292772 > K> > K> Log: > K> Add missed relpbuf() for a smallfs page-in. > K> > K> Reported by: Shawn Webb > K> Tested by: pho > K> Sponsored by: The FreeBSD Foundation > K> > K> Modified: > K> head/sys/vm/vnode_pager.c > K> > K> Modified: head/sys/vm/vnode_pager.c > K> > == > K> --- head/sys/vm/vnode_pager.cSun Dec 27 14:39:47 2015 > (r292771) > K> +++ head/sys/vm/vnode_pager.cSun Dec 27 14:42:39 2015 > (r292772) > K> @@ -806,6 +806,7 @@ vnode_pager_generic_getpages(struct vnod > K> * than a page size, then use special small filesystem code. > K> */ > K> if (pagesperblock == 0) { > K> +relpbuf(bp, freecnt); > K> for (i = 0; i < count; i++) { > K> PCPU_INC(cnt.v_vnodein); > K> PCPU_INC(cnt.v_vnodepgsin); > > The reason for this bug is that I tried to move the (pagesperblock == 0) > block above the call to getpbuf(). > > We actually know that filesystem is "small" at the very beginning of the > function and we can branch into "small filesystem" pager immediately. > > Later I moved the block back to its place, simply because new place > wasn't tested properly. And forgot to restore relpbuf. > > What filesystem did you use to show up the bug? I'm about to test the > variant with immediate branching. Shawn, would you be able to test > a patch if I produce one? > > Isofs, and just take the snapshot from Dec. 17. > -- > 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 > " > ___ 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: r292890 - in head/sys/x86: include x86
Author: kib Date: Tue Dec 29 22:14:21 2015 New Revision: 292890 URL: https://svnweb.freebsd.org/changeset/base/292890 Log: Add standard extended feature bit 6 from the Intel SDM rev. 57, which indicates that data-pointer in the saved x87 FPU state is only updated on FPU exceptions. Sponsored by: The FreeBSD Foundation MFC after:1 week Modified: head/sys/x86/include/specialreg.h head/sys/x86/x86/identcpu.c Modified: head/sys/x86/include/specialreg.h == --- head/sys/x86/include/specialreg.h Tue Dec 29 21:54:43 2015 (r292889) +++ head/sys/x86/include/specialreg.h Tue Dec 29 22:14:21 2015 (r292890) @@ -335,6 +335,7 @@ #defineCPUID_STDEXT_BMI1 0x0008 #defineCPUID_STDEXT_HLE0x0010 #defineCPUID_STDEXT_AVX2 0x0020 +#defineCPUID_STDEXT_FDP_EXC0x0040 #defineCPUID_STDEXT_SMEP 0x0080 #defineCPUID_STDEXT_BMI2 0x0100 #defineCPUID_STDEXT_ERMS 0x0200 Modified: head/sys/x86/x86/identcpu.c == --- head/sys/x86/x86/identcpu.c Tue Dec 29 21:54:43 2015(r292889) +++ head/sys/x86/x86/identcpu.c Tue Dec 29 22:14:21 2015(r292890) @@ -932,6 +932,8 @@ printcpuinfo(void) "\005HLE" /* Advanced Vector Instructions 2 */ "\006AVX2" + /* FDP_EXCPTN_ONLY */ + "\007FDPEXC" /* Supervisor Mode Execution Prot. */ "\010SMEP" /* Bit Manipulation Instructions */ ___ 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: r292891 - head/sys/arm/arm
Author: ian Date: Tue Dec 29 22:18:35 2015 New Revision: 292891 URL: https://svnweb.freebsd.org/changeset/base/292891 Log: Bring some of the recent locore-v4.S improvements into locore-V6... - Map all 4GB as VA=PA so that args passed in from a bootloader can be accessed regardless of where they are. - Figure out the kernel load address by directly masking the PC rather then by doing pc-relative math on the _start symbol. - For EARLY_PRINTF support, map device memory as uncacheable (no-op for ARM_NEW_PMAP because all TEX types resolve to uncacheable). Modified: head/sys/arm/arm/locore-v6.S Modified: head/sys/arm/arm/locore-v6.S == --- head/sys/arm/arm/locore-v6.STue Dec 29 22:14:21 2015 (r292890) +++ head/sys/arm/arm/locore-v6.STue Dec 29 22:18:35 2015 (r292891) @@ -153,46 +153,49 @@ ASENTRY_NP(_start) * Build page table from scratch. */ - /* Calculate the physical address of the startup pagetable. */ + /* +* Figure out the physical address we're loaded at by assuming this +* entry point code is in the first L1 section and so if we clear the +* offset bits of the pc that will give us the section-aligned load +* address, which remains in r5 throughout all the following code. +*/ + ldr r2, =(L1_S_OFFSET) + bic r5, pc, r2 + + /* Find the delta between VA and PA, result stays in r0 throughout. */ adr r0, Lpagetable bl translate_va_to_pa - /* Clear boot page table */ - mov r1, r0 - mov r2, L1_TABLE_SIZE - mov r3,#0 -1: str r3, [r1], #4 - subsr2, #4 - bgt 1b - - /* -* Map PA == VA + /* +* First map the entire 4GB address space as VA=PA. It's mapped as +* normal (cached) memory because it's for things like accessing the +* parameters passed in from the bootloader, which might be at any +* physical address, different for every platform. */ - /* Find the start kernels load address */ - adr r5, _start - ldr r2, =(PTE1_OFFSET) - bic r5, r2 - mov r1, r5 - mov r2, r5 - /* Map 64MiB, preserved over calls to build_pagetables */ - mov r3, #64 + mov r1, #0 + mov r2, #0 + mov r3, #4096 bl build_pagetables - /* Create the kernel map to jump to */ + /* +* Next we do 64MiB starting at the physical load address, mapped to +* the VA the kernel is linked for. +*/ mov r1, r5 ldr r2, =(KERNVIRTADDR) + mov r3, #64 bl build_pagetables + /* Create a device mapping for early_printf if specified. */ #if defined(SOCDEV_PA) && defined(SOCDEV_VA) - /* Create the custom map (1MB) used for early_printf(). */ ldr r1, =SOCDEV_PA ldr r2, =SOCDEV_VA mov r3, #1 - bl build_pagetables + bl build_device_pagetables #endif bl init_mmu - /* Switch to virtual addresses. */ + /* Transition the PC from physical to virtual addressing. */ ldr pc, =1f 1: @@ -394,6 +397,15 @@ END(reinit_mmu) * * Addresses must be 1MiB aligned */ +build_device_pagetables: +#if defined(ARM_NEW_PMAP) + ldr r4, =PTE1_V|PTE1_A|PTE1_AP_KRW|TEX1_CLASS_0 +#elif defined(SMP) + ldr r4, =(L1_TYPE_S|L1_S_AP(AP_KRW)|L1_SHARED) +#else + ldr r4, =(L1_TYPE_S|L1_S_AP(AP_KRW)) +#endif + b 1f build_pagetables: /* Set the required page attributed */ #if defined(ARM_NEW_PMAP) @@ -403,18 +415,19 @@ build_pagetables: #else ldr r4, =(L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW)) #endif +1: orr r1, r4 /* Move the virtual address to the correct bit location */ lsr r2, #(PTE1_SHIFT - 2) mov r4, r3 -1: +2: str r1, [r0, r2] add r2, r2, #4 add r1, r1, #(PTE1_SIZE) addsr4, r4, #-1 - bhi 1b + bhi 2b mov pc, lr ___ 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: r292809 - head/lib/libc/stdio
On Tue, 2015-12-29 at 11:37 -0800, John Baldwin wrote: > On Monday, December 28, 2015 01:01:26 PM Warner Losh wrote: > > I'll look at that, but I don't think posix_memalign is the right > > way to go. > > The alignment of FILE is more strict than posix_memalign will > > return. Ian's > > idea of __alignof__ is the way to go. We allocate them in one block > > on > > purpose for performance, and posix_memalign would be a one at a > > time affair. > > posix_memalign gives you whatever alignment you ask for. Using > __alignof__ > to determine the alignment instead of hardcoding sizeof(int64_t) > would > certainly be an improvement. If you move the glue after the FILE > objects > then you can use posix_memalign() directly as so: > > void *mem; > int error; > > error = posix_memalign(&mem, MAX(ALIGNBYTES, > __alignof__(mbstate_t)), > n * sizeof(FILE) + sizeof(*g)); > if (error) > return (NULL); > p = (FILE *)mem; > g = (struct glue *)(p + n); > g->next = NULL; > g->niobs = n; > g->iobs = p; > ... > > (This presumes that the requested alignment of 'struct glue' is less > than > the alignment needed by FILE which should be true.) > If there's going to be an assumption that __alignof__(glue) <= __alignof__(FILE), it might be nice to have a static_assert() of that to prevent a future time bomb similar to the one that exploded on arm when it turned out the opposite assumption was wrong. -- 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"
svn commit: r292892 - head/sys/kern
Author: jhb Date: Tue Dec 29 23:16:20 2015 New Revision: 292892 URL: https://svnweb.freebsd.org/changeset/base/292892 Log: Call kern_thr_exit() instead of duplicating it. This code is missing the racct_subr() call from kern_thr_exit() and would require further code duplication in future changes. Reviewed by: kib MFC after:1 week Modified: head/sys/kern/kern_thread.c Modified: head/sys/kern/kern_thread.c == --- head/sys/kern/kern_thread.c Tue Dec 29 22:18:35 2015(r292891) +++ head/sys/kern/kern_thread.c Tue Dec 29 23:16:20 2015(r292892) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -942,7 +943,6 @@ thread_suspend_check(int return_instead) */ if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread != td)) { PROC_UNLOCK(p); - tidhash_remove(td); /* * Allow Linux emulation layer to do some work @@ -950,13 +950,8 @@ thread_suspend_check(int return_instead) */ if (__predict_false(p->p_sysent->sv_thread_detach != NULL)) (p->p_sysent->sv_thread_detach)(td); - - PROC_LOCK(p); - tdsigcleanup(td); - umtx_thread_exit(td); - PROC_SLOCK(p); - thread_stopped(p); - thread_exit(); + kern_thr_exit(td); + panic("stopped thread did not exit"); } PROC_SLOCK(p); ___ 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: r292809 - head/lib/libc/stdio
On Tuesday, December 29, 2015 03:51:29 PM Ian Lepore wrote: > On Tue, 2015-12-29 at 11:37 -0800, John Baldwin wrote: > > On Monday, December 28, 2015 01:01:26 PM Warner Losh wrote: > > > I'll look at that, but I don't think posix_memalign is the right > > > way to go. > > > The alignment of FILE is more strict than posix_memalign will > > > return. Ian's > > > idea of __alignof__ is the way to go. We allocate them in one block > > > on > > > purpose for performance, and posix_memalign would be a one at a > > > time affair. > > > > posix_memalign gives you whatever alignment you ask for. Using > > __alignof__ > > to determine the alignment instead of hardcoding sizeof(int64_t) > > would > > certainly be an improvement. If you move the glue after the FILE > > objects > > then you can use posix_memalign() directly as so: > > > > void *mem; > > int error; > > > > error = posix_memalign(&mem, MAX(ALIGNBYTES, > > __alignof__(mbstate_t)), > > n * sizeof(FILE) + sizeof(*g)); > > if (error) > > return (NULL); > > p = (FILE *)mem; > > g = (struct glue *)(p + n); > > g->next = NULL; > > g->niobs = n; > > g->iobs = p; > > ... > > > > (This presumes that the requested alignment of 'struct glue' is less > > than > > the alignment needed by FILE which should be true.) > > > > If there's going to be an assumption that __alignof__(glue) <= > __alignof__(FILE), it might be nice to have a static_assert() of that > to prevent a future time bomb similar to the one that exploded on arm > when it turned out the opposite assumption was wrong. A static assert seems sensible, yes. -- John Baldwin ___ 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: r292894 - in head: sys/kern sys/sys tests/sys/kern
Author: jhb Date: Tue Dec 29 23:25:26 2015 New Revision: 292894 URL: https://svnweb.freebsd.org/changeset/base/292894 Log: Add ptrace(2) reporting for LWP events. Add two new LWPINFO flags: PL_FLAG_BORN and PL_FLAG_EXITED for reporting thread creation and destruction. Newly created threads will stop to report PL_FLAG_BORN before returning to userland and exiting threads will stop to report PL_FLAG_EXIT before exiting completely. Both of these events are only enabled and reported if PT_LWP_EVENTS is enabled on a process. Modified: head/sys/kern/kern_fork.c head/sys/kern/kern_sig.c head/sys/kern/kern_thr.c head/sys/kern/sys_process.c head/sys/sys/proc.h head/sys/sys/ptrace.h head/tests/sys/kern/ptrace_test.c Modified: head/sys/kern/kern_fork.c == --- head/sys/kern/kern_fork.c Tue Dec 29 23:24:10 2015(r292893) +++ head/sys/kern/kern_fork.c Tue Dec 29 23:25:26 2015(r292894) @@ -1066,7 +1066,7 @@ fork_return(struct thread *td, struct tr cv_broadcast(&p->p_dbgwait); } PROC_UNLOCK(p); - } else if (p->p_flag & P_TRACED) { + } else if (p->p_flag & P_TRACED || td->td_dbgflags & TDB_BORN) { /* * This is the start of a new thread in a traced * process. Report a system call exit event. @@ -1074,9 +1074,10 @@ fork_return(struct thread *td, struct tr PROC_LOCK(p); td->td_dbgflags |= TDB_SCX; _STOPEVENT(p, S_SCX, td->td_dbg_sc_code); - if ((p->p_stops & S_PT_SCX) != 0) + if ((p->p_stops & S_PT_SCX) != 0 || + (td->td_dbgflags & TDB_BORN) != 0) ptracestop(td, SIGTRAP); - td->td_dbgflags &= ~TDB_SCX; + td->td_dbgflags &= ~(TDB_SCX | TDB_BORN); PROC_UNLOCK(p); } Modified: head/sys/kern/kern_sig.c == --- head/sys/kern/kern_sig.cTue Dec 29 23:24:10 2015(r292893) +++ head/sys/kern/kern_sig.cTue Dec 29 23:25:26 2015(r292894) @@ -2501,7 +2501,12 @@ ptracestop(struct thread *td, int sig) td->td_tid, p->p_pid, td->td_dbgflags, sig); PROC_SLOCK(p); while ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_XSIG)) { - if (p->p_flag & P_SINGLE_EXIT) { + if (p->p_flag & P_SINGLE_EXIT && + !(td->td_dbgflags & TDB_EXIT)) { + /* +* Ignore ptrace stops except for thread exit +* events when the process exits. +*/ td->td_dbgflags &= ~TDB_XSIG; PROC_SUNLOCK(p); return (sig); Modified: head/sys/kern/kern_thr.c == --- head/sys/kern/kern_thr.cTue Dec 29 23:24:10 2015(r292893) +++ head/sys/kern/kern_thr.cTue Dec 29 23:25:26 2015(r292894) @@ -253,6 +253,8 @@ thread_create(struct thread *td, struct thread_unlock(td); if (P_SHOULDSTOP(p)) newtd->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; + if (p->p_flag2 & P2_LWP_EVENTS) + newtd->td_dbgflags |= TDB_BORN; /* * Copy the existing thread VM policy into the new thread. @@ -322,29 +324,54 @@ kern_thr_exit(struct thread *td) p = td->td_proc; - rw_wlock(&tidhash_lock); + /* +* If all of the threads in a process call this routine to +* exit (e.g. all threads call pthread_exit()), exactly one +* thread should return to the caller to terminate the process +* instead of the thread. +* +* Checking p_numthreads alone is not sufficient since threads +* might be committed to terminating while the PROC_LOCK is +* dropped in either ptracestop() or while removing this thread +* from the tidhash. Instead, the p_pendingexits field holds +* the count of threads in either of those states and a thread +* is considered the "last" thread if all of the other threads +* in a process are already terminating. +*/ PROC_LOCK(p); - - if (p->p_numthreads != 1) { - racct_sub(p, RACCT_NTHR, 1); - LIST_REMOVE(td, td_hash); - rw_wunlock(&tidhash_lock); - tdsigcleanup(td); - umtx_thread_exit(td); - PROC_SLOCK(p); - thread_stopped(p); - thread_exit(); - /* NOTREACHED */ + if (p->p_numthreads == p->p_pendingexits + 1) { + /* +* Ignore attempts to shut down last thread in the +* proc. This will actually call _e