svn commit: r368606 - head/usr.bin/calendar
Author: se Date: Sun Dec 13 09:38:50 2020 New Revision: 368606 URL: https://svnweb.freebsd.org/changeset/base/368606 Log: Fix WITHOUT_ICONV build There was an unprotected use of nl_langinfo() to determine the order of day vs. month in the generated output. When building without ICONV support, the order will be: month, day. Modified: head/usr.bin/calendar/events.c Modified: head/usr.bin/calendar/events.c == --- head/usr.bin/calendar/events.c Sun Dec 13 05:34:14 2020 (r368605) +++ head/usr.bin/calendar/events.c Sun Dec 13 09:38:50 2020 (r368606) @@ -202,9 +202,13 @@ event_print_all(FILE *fp) struct event *e; struct tm tm; char dbuf[80]; +#ifdef WITH_ICONV static int d_first; d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); +#else +#defined_first 0 +#endif while (walkthrough_dates(&e) != 0) { if (e) { ___ 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: r368606 - head/usr.bin/calendar
Stefan Eßer wrote: Author: se Date: Sun Dec 13 09:38:50 2020 New Revision: 368606 URL: https://svnweb.freebsd.org/changeset/base/368606 Log: Fix WITHOUT_ICONV build There was an unprotected use of nl_langinfo() to determine the order of day vs. month in the generated output. That's strange, nl_langinfo() is standard and its visibility should not (and does not?) depend on WITH/WITHOUT_ICONV. May be just move langinfo.h include outside of "#ifdef WITH_ICONV" block? When building without ICONV support, the order will be: month, day. Modified: head/usr.bin/calendar/events.c Modified: head/usr.bin/calendar/events.c == --- head/usr.bin/calendar/events.c Sun Dec 13 05:34:14 2020 (r368605) +++ head/usr.bin/calendar/events.c Sun Dec 13 09:38:50 2020 (r368606) @@ -202,9 +202,13 @@ event_print_all(FILE *fp) struct event *e; struct tm tm; char dbuf[80]; +#ifdef WITH_ICONV static int d_first; d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); +#else +#defined_first 0 +#endif while (walkthrough_dates(&e) != 0) { if (e) { ___ 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: r368608 - in head: contrib/libarchive/libarchive contrib/libarchive/libarchive/test lib/libarchive
Author: mm Date: Sun Dec 13 16:26:37 2020 New Revision: 368608 URL: https://svnweb.freebsd.org/changeset/base/368608 Log: MFV r368607: Sync libarchive with vendor. Vendor changes: Issue #1461: Unbreak build without lzma Issue #1462: warc reader: Fix build with gcc11 Issue #1463: Fix code compatibility in test_archive_read_support.c Issue #1464: Use built-in strnlen on platforms where not available Issue #1465: warc reader: fix undefined behaviour in deconst() function MFC after:3 days X-MFC-With: 368234 Modified: head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c head/contrib/libarchive/libarchive/archive_read_support_format_warc.c head/contrib/libarchive/libarchive/archive_read_support_format_zip.c head/contrib/libarchive/libarchive/test/test_archive_read_support.c head/lib/libarchive/config_freebsd.h Directory Properties: head/contrib/libarchive/ (props changed) Modified: head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c == --- head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Sun Dec 13 15:29:19 2020(r368607) +++ head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Sun Dec 13 16:26:37 2020(r368608) @@ -136,6 +136,9 @@ static int skip(struct archive_read *a); static int read_header(struct archive_read *, struct archive_entry *); static int64_t mtree_atol(char **, int base); +#ifndef HAVE_STRNLEN +static size_t mtree_strnlen(const char *, size_t); +#endif /* * There's no standard for TIME_T_MAX/TIME_T_MIN. So we compute them @@ -187,6 +190,24 @@ get_time_t_min(void) #endif } +#ifdef HAVE_STRNLEN +#define mtree_strnlen(a,b) strnlen(a,b) +#else +static size_t +mtree_strnlen(const char *p, size_t maxlen) +{ + size_t i; + + for (i = 0; i <= maxlen; i++) { + if (p[i] == 0) + break; + } + if (i > maxlen) + return (-1);/* invalid */ + return (i); +} +#endif + static int archive_read_format_mtree_options(struct archive_read *a, const char *key, const char *val) @@ -1540,7 +1561,7 @@ parse_digest(struct archive_read *a, struct archive_en len *= 2; - if (strnlen(digest, len+1) != len) { + if (mtree_strnlen(digest, len+1) != len) { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "incorrect digest length, ignoring"); return ARCHIVE_WARN; Modified: head/contrib/libarchive/libarchive/archive_read_support_format_warc.c == --- head/contrib/libarchive/libarchive/archive_read_support_format_warc.c Sun Dec 13 15:29:19 2020(r368607) +++ head/contrib/libarchive/libarchive/archive_read_support_format_warc.c Sun Dec 13 16:26:37 2020(r368608) @@ -127,7 +127,7 @@ static int _warc_skip(struct archive_read *a); static int _warc_rdhdr(struct archive_read *a, struct archive_entry *e); /* private routines */ -static unsigned int _warc_rdver(const char buf[10], size_t bsz); +static unsigned int _warc_rdver(const char *buf, size_t bsz); static unsigned int _warc_rdtyp(const char *buf, size_t bsz); static warc_string_t _warc_rduri(const char *buf, size_t bsz); static ssize_t _warc_rdlen(const char *buf, size_t bsz); @@ -443,7 +443,7 @@ _warc_skip(struct archive_read *a) static void* deconst(const void *c) { - return (char *)0x1 + (((const char *)c) - (const char *)0x1); + return (void *)(uintptr_t)c; } static char* Modified: head/contrib/libarchive/libarchive/archive_read_support_format_zip.c == --- head/contrib/libarchive/libarchive/archive_read_support_format_zip.c Sun Dec 13 15:29:19 2020(r368607) +++ head/contrib/libarchive/libarchive/archive_read_support_format_zip.c Sun Dec 13 16:26:37 2020(r368608) @@ -899,6 +899,7 @@ process_extra(struct archive_read *a, struct archive_e return ARCHIVE_OK; } +#if HAVE_LZMA_H && HAVE_LIBLZMA /* * Auxiliary function to uncompress data chunk from zipx archive * (zip with lzma compression). @@ -971,6 +972,7 @@ zipx_lzma_uncompress_buffer(const char *compressed_buf free(lzma_alone_compressed_buffer); return status; } +#endif /* * Assumes file pointer is at beginning of local file header. Modified: head/contrib/libarchive/libarchive/test/test_archive_read_support.c == --- head/contrib/libarchive/libarchive/test/test_archive_read_support.c Sun Dec 13 15:29:19 2020(r368607) +++ head/contrib/libarchive/libarchive/test/test_archive_read_support.c Sun Dec 13 16:26:37 2020(r368608)
svn commit: r368609 - in head/sys: kern sys
Author: mjg Date: Sun Dec 13 18:06:24 2020 New Revision: 368609 URL: https://svnweb.freebsd.org/changeset/base/368609 Log: fd: fix fdrop prediction when closing a fd Most of the time this is the last reference, contrary to typical fdrop use. Modified: head/sys/kern/kern_descrip.c head/sys/sys/file.h Modified: head/sys/kern/kern_descrip.c == --- head/sys/kern/kern_descrip.cSun Dec 13 16:26:37 2020 (r368608) +++ head/sys/kern/kern_descrip.cSun Dec 13 18:06:24 2020 (r368609) @@ -2766,7 +2766,7 @@ closef(struct file *fp, struct thread *td) FILEDESC_XUNLOCK(fdp); } } - return (fdrop(fp, td)); + return (fdrop_close(fp, td)); } /* Modified: head/sys/sys/file.h == --- head/sys/sys/file.h Sun Dec 13 16:26:37 2020(r368608) +++ head/sys/sys/file.h Sun Dec 13 18:06:24 2020(r368609) @@ -299,6 +299,17 @@ fhold(struct file *fp) _error; \ }) +#definefdrop_close(fp, td) ({ \ + struct file *_fp; \ + int _error; \ + \ + _error = 0; \ + _fp = (fp); \ + if (__predict_true(refcount_release(&_fp->f_count)))\ + _error = _fdrop(_fp, td); \ + _error; \ +}) + static __inline fo_rdwr_t fo_read; static __inline fo_rdwr_t fo_write; static __inline fo_truncate_t fo_truncate; ___ 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: r368609 - in head/sys: kern sys
On Sun, 13 Dec 2020 at 18:06, Mateusz Guzik wrote: > > Author: mjg > Date: Sun Dec 13 18:06:24 2020 > New Revision: 368609 > URL: https://svnweb.freebsd.org/changeset/base/368609 > > Log: > fd: fix fdrop prediction when closing a fd > > Most of the time this is the last reference, contrary to typical fdrop use. > > Modified: > head/sys/kern/kern_descrip.c > head/sys/sys/file.h > > Modified: head/sys/kern/kern_descrip.c > == > --- head/sys/kern/kern_descrip.cSun Dec 13 16:26:37 2020 > (r368608) > +++ head/sys/kern/kern_descrip.cSun Dec 13 18:06:24 2020 > (r368609) > @@ -2766,7 +2766,7 @@ closef(struct file *fp, struct thread *td) > FILEDESC_XUNLOCK(fdp); > } > } > - return (fdrop(fp, td)); > + return (fdrop_close(fp, td)); > } > > /* > > Modified: head/sys/sys/file.h > == > --- head/sys/sys/file.h Sun Dec 13 16:26:37 2020(r368608) > +++ head/sys/sys/file.h Sun Dec 13 18:06:24 2020(r368609) > @@ -299,6 +299,17 @@ fhold(struct file *fp) > _error; \ > }) > > +#definefdrop_close(fp, td) ({ \ > + struct file *_fp; \ > + int _error; \ > + \ > + _error = 0; \ > + _fp = (fp); \ > + if (__predict_true(refcount_release(&_fp->f_count)))\ > + _error = _fdrop(_fp, td); \ > + _error; \ > +}) > + > static __inline fo_rdwr_t fo_read; > static __inline fo_rdwr_t fo_write; > static __inline fo_truncate_t fo_truncate; Wouldn't this be more readable as a static __inline function (or if you are concerned about it not being inlined, __always_inline)? Also means you can drop the temporary _fp variable that's there to avoid side-effects in macro args. Regards, Alex ___ 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: r368606 - head/usr.bin/calendar
Am 13.12.20 um 12:13 schrieb Yuri Pankov: Stefan Eßer wrote: Author: se Date: Sun Dec 13 09:38:50 2020 New Revision: 368606 URL: https://svnweb.freebsd.org/changeset/base/368606 Log: Fix WITHOUT_ICONV build There was an unprotected use of nl_langinfo() to determine the order of day vs. month in the generated output. That's strange, nl_langinfo() is standard and its visibility should not (and does not?) depend on WITH/WITHOUT_ICONV. May be just move langinfo.h include outside of "#ifdef WITH_ICONV" block? Yes, you are perfectly right ... I had noticed that WITHOUT_ICONV lead to a problem due to the missing prototype, but I had not seen that this was due to the include of langinfo.h being conditional on WITH_ICONV. I'll revert this commit and move the include of langinfo.h out of the conditional block, as suggested by you. Thanks for pointing this out! Best regards, STefan OpenPGP_signature Description: OpenPGP digital signature
svn commit: r368610 - head/usr.bin/calendar
Author: se Date: Sun Dec 13 19:03:38 2020 New Revision: 368610 URL: https://svnweb.freebsd.org/changeset/base/368610 Log: Revert r368606 The issue will be fixed in a different way. Reported by: yuripv Modified: head/usr.bin/calendar/events.c Modified: head/usr.bin/calendar/events.c == --- head/usr.bin/calendar/events.c Sun Dec 13 18:06:24 2020 (r368609) +++ head/usr.bin/calendar/events.c Sun Dec 13 19:03:38 2020 (r368610) @@ -202,13 +202,9 @@ event_print_all(FILE *fp) struct event *e; struct tm tm; char dbuf[80]; -#ifdef WITH_ICONV static int d_first; d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); -#else -#defined_first 0 -#endif while (walkthrough_dates(&e) != 0) { if (e) { ___ 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: r368611 - head/usr.bin/calendar
Author: se Date: Sun Dec 13 19:06:59 2020 New Revision: 368611 URL: https://svnweb.freebsd.org/changeset/base/368611 Log: Fix WITHOUT_ICONV build Move the include of langinfo.h out of the WITH_ICONV condition block, since it is not dependent on ICONV. This was correct when nl_langinfo() had only been called in the WITH_ICONV case, but that is no longer the case. Submitted by: yuripv Modified: head/usr.bin/calendar/events.c Modified: head/usr.bin/calendar/events.c == --- head/usr.bin/calendar/events.c Sun Dec 13 19:03:38 2020 (r368610) +++ head/usr.bin/calendar/events.c Sun Dec 13 19:06:59 2020 (r368611) @@ -32,13 +32,13 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include #ifdef WITH_ICONV #include #include -#include static iconv_t conv = (iconv_t)-1; static char *currentEncoding = 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"
Re: svn commit: r368609 - in head/sys: kern sys
Unfortunately inlines mess with __FILE__/__LINE__ by showing the implementation instead of the consumer. This in particular matters with https://reviews.freebsd.org/D27600 I failed to find replacements for __ macros which don't suffer the problem. On 12/13/20, Alexander Richardson wrote: > On Sun, 13 Dec 2020 at 18:06, Mateusz Guzik wrote: >> >> Author: mjg >> Date: Sun Dec 13 18:06:24 2020 >> New Revision: 368609 >> URL: https://svnweb.freebsd.org/changeset/base/368609 >> >> Log: >> fd: fix fdrop prediction when closing a fd >> >> Most of the time this is the last reference, contrary to typical fdrop >> use. >> >> Modified: >> head/sys/kern/kern_descrip.c >> head/sys/sys/file.h >> >> Modified: head/sys/kern/kern_descrip.c >> == >> --- head/sys/kern/kern_descrip.cSun Dec 13 16:26:37 2020 >> (r368608) >> +++ head/sys/kern/kern_descrip.cSun Dec 13 18:06:24 2020 >> (r368609) >> @@ -2766,7 +2766,7 @@ closef(struct file *fp, struct thread *td) >> FILEDESC_XUNLOCK(fdp); >> } >> } >> - return (fdrop(fp, td)); >> + return (fdrop_close(fp, td)); >> } >> >> /* >> >> Modified: head/sys/sys/file.h >> == >> --- head/sys/sys/file.h Sun Dec 13 16:26:37 2020(r368608) >> +++ head/sys/sys/file.h Sun Dec 13 18:06:24 2020(r368609) >> @@ -299,6 +299,17 @@ fhold(struct file *fp) >> _error; \ >> }) >> >> +#definefdrop_close(fp, td) ({ \ >> + struct file *_fp; \ >> + int _error; \ >> + \ >> + _error = 0; \ >> + _fp = (fp); \ >> + if (__predict_true(refcount_release(&_fp->f_count)))\ >> + _error = _fdrop(_fp, td); \ >> + _error; \ >> +}) >> + >> static __inline fo_rdwr_t fo_read; >> static __inline fo_rdwr_t fo_write; >> static __inline fo_truncate_t fo_truncate; > > Wouldn't this be more readable as a static __inline function (or if > you are concerned about it not being inlined, __always_inline)? Also > means you can drop the temporary _fp variable that's there to avoid > side-effects in macro args. > > Regards, > Alex > -- 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: r364761 - in head: share/mk sys/conf sys/modules/cloudabi32 sys/modules/cloudabi64 sys/modules/linux sys/modules/linux64
On Tue, Aug 25, 2020 at 6:30 AM Alex Richardson wrote: > > Author: arichardson > Date: Tue Aug 25 13:30:03 2020 > New Revision: 364761 > URL: https://svnweb.freebsd.org/changeset/base/364761 > > Log: > Pass -fuse-ld=/path/to/ld if ${LD} != "ld" > > This is needed so that setting LD/XLD is not ignored when linking with $CC > instead of directly using $LD. Currently only clang accepts an absolute > path for -fuse-ld= (Clang 12+ will add a new --ld-path flag), so we now > warn when building with GCC and $LD != "ld" since that might result in the > wrong linker being used. > > We have been setting XLD=/path/to/cheri/ld.lld in CheriBSD for a long time > and > used a similar version of this patch to avoid linking with /usr/bin/ld. > This change is also required when building FreeBSD on an Ubuntu with Clang: > In that case we set XCC=/usr/lib/llvm-10/bin/clang and since > /usr/lib/llvm-10/bin/ does not contain a "ld" binary the build fails with > `clang: error: unable to execute command: Executable "ld" doesn't exist!` > unless we pass -fuse-ld=/usr/lib/llvm-10/bin/ld.lld. > > This change passes -fuse-ld instead of copying ${XLD} to WOLRDTMP/bin/ld > since then we would have to ensure that this file does not exist while > building the bootstrap tools. The cross-linker might not be compatible with > the host linker (e.g. when building on macos: host-linker= Mach-O > /usr/bin/ld, > cross-linker=LLVM ld.lld). > > Reviewed By: brooks, emaste > Differential Revision: https://reviews.freebsd.org/D26055 > > Modified: > head/share/mk/bsd.sys.mk > head/sys/conf/kern.mk > head/sys/conf/kern.post.mk > head/sys/modules/cloudabi32/Makefile > head/sys/modules/cloudabi64/Makefile > head/sys/modules/linux/Makefile > head/sys/modules/linux64/Makefile > > Modified: head/share/mk/bsd.sys.mk > == > --- head/share/mk/bsd.sys.mkTue Aug 25 13:29:57 2020(r364760) > +++ head/share/mk/bsd.sys.mkTue Aug 25 13:30:03 2020(r364761) > @@ -284,6 +284,19 @@ CFLAGS+= ERROR-tried-to-rebuild-during-make-install > .endif > .endif > > +# Please keep this if in sync with kern.mk > +.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld") > +# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld". > +# Note: Clang 12+ will prefer --ld-path= over -fuse-ld=. > +.if ${COMPILER_TYPE} == "clang" > +LDFLAGS+= -fuse-ld=${LD:[1]} > +.else > +# GCC does not support an absolute path for -fuse-ld so we just print this > +# warning instead and let the user add the required symlinks. > +.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not > supported FYI: This causes a huge amount of wrong and irrelevant warnings in the build log for gcc cross compilers with XLD set, such as the toolchain from pkg install amd64-xtoolchain-gcc. That causes XLD to be set (via CROSS_BINUTILS_PREFIX in Makefile.inc1) to a path which is indeed the default linker for the cross compiler. The warnings are harmless, but annoying. Sorry, I don't have a suggestion for a better method. You can see an example in the build log from a gcc build in CI here (although note that the build currently fails for unrelated reasons): https://ci.freebsd.org/job/FreeBSD-head-amd64-gcc6_build/3131 > +.endif > +.endif > + > # Tell bmake not to mistake standard targets for things to be searched for > # or expect to ever be up-to-date. > PHONY_NOTMAIN = analyze afterdepend afterinstall all beforedepend > beforeinstall \ > > Modified: head/sys/conf/kern.mk > == > --- head/sys/conf/kern.mk Tue Aug 25 13:29:57 2020(r364760) > +++ head/sys/conf/kern.mk Tue Aug 25 13:30:03 2020(r364761) > @@ -270,6 +270,22 @@ CFLAGS+=-std=iso9899:1999 > CFLAGS+=-std=${CSTD} > .endif # CSTD > > +# Please keep this if in sync with bsd.sys.mk > +.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld") > +# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld". > +# Note: Clang 12+ will prefer --ld-path= over -fuse-ld=. > +.if ${COMPILER_TYPE} == "clang" > +# Note: unlike bsd.sys.mk we can't use LDFLAGS here since that is used for > the > +# flags required when linking the kernel. We don't need those flags when > +# building the vdsos. However, we do need -fuse-ld, so use ${CCLDFLAGS} > instead. > +CCLDFLAGS+=-fuse-ld=${LD:[1]} > +.else > +# GCC does not support an absolute path for -fuse-ld so we just print this > +# warning instead and let the user add the required symlinks. > +.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not > supported > +.endif > +.endif > + > # Set target-specific linker emulation name. > LD_EMULATION_aarch64=aarch64elf > LD_EMULATION_amd64=elf_x86_64_fbsd > > Modified: head/sys/conf/kern.po
svn commit: r368612 - head/sys/kern
Author: kib Date: Sun Dec 13 19:43:45 2020 New Revision: 368612 URL: https://svnweb.freebsd.org/changeset/base/368612 Log: Correct indent. Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/subr_sleepqueue.c Modified: head/sys/kern/subr_sleepqueue.c == --- head/sys/kern/subr_sleepqueue.c Sun Dec 13 19:06:59 2020 (r368611) +++ head/sys/kern/subr_sleepqueue.c Sun Dec 13 19:43:45 2020 (r368612) @@ -462,7 +462,7 @@ sleepq_check_ast_sc_locked(struct thread *td, struct s p = td->td_proc; CTR3(KTR_PROC, "sleepq catching signals: thread %p (pid %ld, %s)", - (void *)td, (long)p->p_pid, td->td_name); + (void *)td, (long)p->p_pid, td->td_name); PROC_LOCK(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"
svn commit: r368613 - head/sys/kern
Author: kib Date: Sun Dec 13 19:45:42 2020 New Revision: 368613 URL: https://svnweb.freebsd.org/changeset/base/368613 Log: Fix TDP_WAKEUP/thr_wake(curthread->td_tid) after r366428. Reported by: arichardson Reviewed by: arichardson, markj Sponsored by: The FreeBSD Foundation Differential revision:https://reviews.freebsd.org/D27597 Modified: head/sys/kern/subr_sleepqueue.c Modified: head/sys/kern/subr_sleepqueue.c == --- head/sys/kern/subr_sleepqueue.c Sun Dec 13 19:43:45 2020 (r368612) +++ head/sys/kern/subr_sleepqueue.c Sun Dec 13 19:45:42 2020 (r368613) @@ -441,12 +441,10 @@ sleepq_check_ast_sc_locked(struct thread *td, struct s mtx_assert(&sc->sc_lock, MA_OWNED); - ret = 0; if ((td->td_pflags & TDP_WAKEUP) != 0) { td->td_pflags &= ~TDP_WAKEUP; - ret = EINTR; thread_lock(td); - return (0); + return (EINTR); } /* ___ 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: r368614 - head/sys/kern
Author: mjg Date: Sun Dec 13 21:28:15 2020 New Revision: 368614 URL: https://svnweb.freebsd.org/changeset/base/368614 Log: vfs: correctly predict last fdrop on failed open Arguably since the count is guaranteed to be 1 the code should be modified to avoid the work. Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c == --- head/sys/kern/vfs_syscalls.cSun Dec 13 19:45:42 2020 (r368613) +++ head/sys/kern/vfs_syscalls.cSun Dec 13 21:28:15 2020 (r368614) @@ -1229,7 +1229,7 @@ success: return (0); bad: KASSERT(indx == -1, ("indx=%d, should be -1", indx)); - fdrop(fp, td); + fdrop_close(fp, td); return (error); } ___ 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: r368615 - head/sys/kern
Author: mjg Date: Sun Dec 13 21:29:39 2020 New Revision: 368615 URL: https://svnweb.freebsd.org/changeset/base/368615 Log: cache: fix ups bad predicts - last level fallback normally sees CREATE; the code should be optimized to not get there for said case - fast path commonly fails with ENOENT Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c == --- head/sys/kern/vfs_cache.c Sun Dec 13 21:28:15 2020(r368614) +++ head/sys/kern/vfs_cache.c Sun Dec 13 21:29:39 2020(r368615) @@ -1824,7 +1824,10 @@ retry: } return (-1); negative_success: - if (__predict_false(cnp->cn_nameiop == CREATE)) { + /* +* We don't get here with regular lookup apart from corner cases. +*/ + if (__predict_true(cnp->cn_nameiop == CREATE)) { if (cnp->cn_flags & ISLASTCN) { counter_u64_add(numnegzaps, 1); error = cache_zap_locked_bucket(ncp, cnp, hash, blp); @@ -1927,7 +1930,7 @@ cache_lookup(struct vnode *dvp, struct vnode **vpp, st } return (-1); negative_success: - if (__predict_false(cnp->cn_nameiop == CREATE)) { + if (cnp->cn_nameiop == CREATE) { if (cnp->cn_flags & ISLASTCN) { vfs_smr_exit(); goto out_fallback; @@ -4589,7 +4592,10 @@ out: case CACHE_FPL_STATUS_HANDLED: MPASS(error != CACHE_FPL_FAILED); cache_fpl_smr_assert_not_entered(fpl); - if (__predict_false(error != 0)) { + /* +* A common error is ENOENT. +*/ + if (error != 0) { ndp->ni_dvp = NULL; ndp->ni_vp = NULL; cache_fpl_cleanup_cnp(cnp); ___ 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: r368616 - head/sys/sys
Author: mjg Date: Sun Dec 13 21:30:42 2020 New Revision: 368616 URL: https://svnweb.freebsd.org/changeset/base/368616 Log: Patch annotation in sigdeferstop Probability flipped since sigdefer handling was moved away from regular VOP calls. Modified: head/sys/sys/signalvar.h Modified: head/sys/sys/signalvar.h == --- head/sys/sys/signalvar.hSun Dec 13 21:29:39 2020(r368615) +++ head/sys/sys/signalvar.hSun Dec 13 21:30:42 2020(r368616) @@ -367,7 +367,7 @@ static inline int sigdeferstop(int mode) { - if (__predict_true(mode == SIGDEFERSTOP_NOP)) + if (__predict_false(mode == SIGDEFERSTOP_NOP)) return (SIGDEFERSTOP_VAL_NCHG); return (sigdeferstop_impl(mode)); } ___ 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: r368617 - head/sys/kern
Author: mjg Date: Sun Dec 13 21:32:19 2020 New Revision: 368617 URL: https://svnweb.freebsd.org/changeset/base/368617 Log: uipc: disable prediction in unp_pcb_lock_peer The branch is not very predictable one way or the other, at least during buildkernel where it only correctly matched 57% of calls. Modified: head/sys/kern/uipc_usrreq.c Modified: head/sys/kern/uipc_usrreq.c == --- head/sys/kern/uipc_usrreq.c Sun Dec 13 21:30:42 2020(r368616) +++ head/sys/kern/uipc_usrreq.c Sun Dec 13 21:32:19 2020(r368617) @@ -382,7 +382,7 @@ unp_pcb_lock_peer(struct unpcb *unp) UNP_PCB_LOCK_ASSERT(unp); unp2 = unp->unp_conn; - if (__predict_false(unp2 == NULL)) + if (unp2 == NULL) return (NULL); if (__predict_false(unp == unp2)) return (unp); ___ 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: r368622 - head/sys/netinet
Author: tuexen Date: Sun Dec 13 23:51:51 2020 New Revision: 368622 URL: https://svnweb.freebsd.org/changeset/base/368622 Log: Harden the handling of outgoing streams in case of an restart or INIT collision. This avouds an out-of-bounce access in case the peer can break the cookie signature. Thanks to Felix Wilhelm from Google for reporting the issue. MFC after:1 week Modified: head/sys/netinet/sctp_input.c Modified: head/sys/netinet/sctp_input.c == --- head/sys/netinet/sctp_input.c Sun Dec 13 23:32:50 2020 (r368621) +++ head/sys/netinet/sctp_input.c Sun Dec 13 23:51:51 2020 (r368622) @@ -1699,7 +1699,9 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle NULL); } asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); - asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams); + if (asoc->pre_open_streams < asoc->streamoutcnt) { + asoc->pre_open_streams = asoc->streamoutcnt; + } if (ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) { /* @@ -1831,7 +1833,9 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle /* move to OPEN state, if not in SHUTDOWN_SENT */ SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); } - asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams); + if (asoc->pre_open_streams < asoc->streamoutcnt) { + asoc->pre_open_streams = asoc->streamoutcnt; + } asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn); asoc->sending_seq = asoc->asconf_seq_out = asoc->str_reset_seq_out = asoc->init_seq_number; asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1; @@ -2108,7 +2112,6 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, in /* process the INIT-ACK info (my info) */ asoc->my_vtag = ntohl(initack_cp->init.initiate_tag); asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); - asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams); asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn); asoc->sending_seq = asoc->asconf_seq_out = asoc->str_reset_seq_out = asoc->init_seq_number; asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 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: r368623 - head/stand/common
Author: jrtc27 Date: Mon Dec 14 00:46:24 2020 New Revision: 368623 URL: https://svnweb.freebsd.org/changeset/base/368623 Log: loader: Print autoboot countdown immediately, not at 9 For the first second otime and ntime are equal so no message gets printed. Instead we should print the countdown right from the start, although we do it at the end of the first iteration so that if a key has already been pressed then the message is suppressed. Reviewed by: imp Approved by: imp Differential Revision:https://reviews.freebsd.org/D26935 Modified: head/stand/common/boot.c Modified: head/stand/common/boot.c == --- head/stand/common/boot.cSun Dec 13 23:51:51 2020(r368622) +++ head/stand/common/boot.cMon Dec 14 00:46:24 2020(r368623) @@ -202,8 +202,9 @@ autoboot(int timeout, char *prompt) } if (timeout >= 0) { - otime = time(NULL); - when = otime + timeout; /* when to boot */ + otime = -1; + ntime = time(NULL); + when = ntime + timeout; /* when to boot */ yes = 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: r368624 - head/sys/mips/mips
Author: jrtc27 Date: Mon Dec 14 00:47:59 2020 New Revision: 368624 URL: https://svnweb.freebsd.org/changeset/base/368624 Log: mips: Fix sub-word atomics implementation These aligned the address but then always used the least significant bits of the value in memory, which is the wrong half 50% of the time for 16-bit atomics and the wrong quarter 75% of the time for 8-bit atomics. These bugs were all present in r178172, the commit that added the mips port, and have remained for its entire existence to date. Reviewed by: jhb (mentor) Approved by: jhb (mentor) Differential Revision:https://reviews.freebsd.org/D27343 Modified: head/sys/mips/mips/support.S Modified: head/sys/mips/mips/support.S == --- head/sys/mips/mips/support.SMon Dec 14 00:46:24 2020 (r368623) +++ head/sys/mips/mips/support.SMon Dec 14 00:47:59 2020 (r368624) @@ -90,6 +90,7 @@ #include #include #include +#include #include #include #include @@ -578,9 +579,14 @@ END(ffs) */ LEAF(atomic_set_16) .setnoreorder - srl a0, a0, 2 # round down address to be 32-bit aligned - sll a0, a0, 2 - andia1, a1, 0x + /* NB: Only bit 1 is masked so the ll catches unaligned inputs */ + andit0, a0, 2 # get unaligned offset + xor a0, a0, t0 # align pointer +#if _BYTE_ORDER == BIG_ENDIAN + xorit0, t0, 2 +#endif + sll t0, t0, 3 # convert byte offset to bit offset + sll a1, a1, t0 # put bits in the right half 1: ll t0, 0(a0) or t0, t0, a1 @@ -600,17 +606,18 @@ END(atomic_set_16) */ LEAF(atomic_clear_16) .setnoreorder - srl a0, a0, 2 # round down address to be 32-bit aligned - sll a0, a0, 2 - nor a1, zero, a1 + /* NB: Only bit 1 is masked so the ll catches unaligned inputs */ + andit0, a0, 2 # get unaligned offset + xor a0, a0, t0 # align pointer +#if _BYTE_ORDER == BIG_ENDIAN + xorit0, t0, 2 +#endif + sll t0, t0, 3 # convert byte offset to bit offset + sll a1, a1, t0 # put bits in the right half + not a1, a1 1: ll t0, 0(a0) - movet1, t0 - andit1, t1, 0x # t1 has the original lower 16 bits - and t1, t1, a1 # t1 has the new lower 16 bits - srl t0, t0, 16 # preserve original top 16 bits - sll t0, t0, 16 - or t0, t0, t1 + and t0, t0, a1 sc t0, 0(a0) beq t0, zero, 1b nop @@ -628,17 +635,23 @@ END(atomic_clear_16) */ LEAF(atomic_subtract_16) .setnoreorder - srl a0, a0, 2 # round down address to be 32-bit aligned - sll a0, a0, 2 + /* NB: Only bit 1 is masked so the ll catches unaligned inputs */ + andit0, a0, 2 # get unaligned offset + xor a0, a0, t0 # align pointer +#if _BYTE_ORDER == BIG_ENDIAN + xorit0, t0, 2 # flip order for big-endian +#endif + sll t0, t0, 3 # convert byte offset to bit offset + sll a1, a1, t0 # put bits in the right half + li t2, 0x + sll t2, t2, t0 # compute mask 1: ll t0, 0(a0) - movet1, t0 - andit1, t1, 0x # t1 has the original lower 16 bits - subut1, t1, a1 - andit1, t1, 0x # t1 has the new lower 16 bits - srl t0, t0, 16 # preserve original top 16 bits - sll t0, t0, 16 - or t0, t0, t1 + subut1, t0, a1 + /* Exploit ((t0 & ~t2) | (t1 & t2)) = t0 ^ ((t0 ^ t1) & t2) */ + xor t1, t0, t1 + and t1, t1, t2 + xor t0, t0, t1 sc t0, 0(a0) beq t0, zero, 1b nop @@ -655,17 +668,23 @@ END(atomic_subtract_16) */ LEAF(atomic_add_16) .setnoreorder - srl a0, a0, 2 # round down address to be 32-bit aligned - sll a0, a0, 2 + /* NB: Only bit 1 is masked so the ll catches unaligned inputs */ + andit0, a0, 2 # get unaligned offset + xor a0, a0, t0 # align pointer +#if _BYTE_ORDER == BIG_ENDIAN + xorit0, t0, 2 # flip order for big-endian +#endif + sll t0, t0, 3 # convert byte offset to bit offset + sll a1, a1, t0 # put bits in the right half + li t2, 0x + sll t2, t2, t0 # compute mask 1: ll t0, 0(a0) - movet1, t0 - andit1, t1, 0x # t1 has the original lower 16 bits - addut1, t1, a1 - andit1, t1, 0x # t1 has the new lower 16 bits - srl t0, t0, 16 # preserve original top 16 bits - sll t0, t0, 16 - or t0, t0, t1 +
svn commit: r368625 - head/lib/libc/string
Author: jrtc27 Date: Mon Dec 14 00:50:45 2020 New Revision: 368625 URL: https://svnweb.freebsd.org/changeset/base/368625 Log: strdup.3: Function appeared in 4.3BSD-Reno, not 4.4BSD Linux claims 4.3BSD, we claim 4.4BSD and OpenBSD claims 4.3BSD-Reno. It turns out that OpenBSD got it right: the function was added in late 1988 a few months after 4.3BSD-Tahoe, well in advance of 4.3BSD-Reno. Reviewed by: bcr Approved by: bcr Differential Revision:https://reviews.freebsd.org/D27392 Modified: head/lib/libc/string/strdup.3 Modified: head/lib/libc/string/strdup.3 == --- head/lib/libc/string/strdup.3 Mon Dec 14 00:47:59 2020 (r368624) +++ head/lib/libc/string/strdup.3 Mon Dec 14 00:50:45 2020 (r368625) @@ -91,7 +91,7 @@ function is specified by The .Fn strdup function first appeared in -.Bx 4.4 . +.Bx 4.3 Reno . The .Fn strndup function was added in ___ 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: r368626 - head/stand/efi/loader/arch/riscv
Author: jrtc27 Date: Mon Dec 14 00:54:05 2020 New Revision: 368626 URL: https://svnweb.freebsd.org/changeset/base/368626 Log: loader: Ignore the .interp section on RISC-V Without this we risk having the .interp section be placed earlier in the file and mess with section offsets; in particular it has been seen to be placed at the start of the file and cause the PE/COFF header to not be at address 0. This is the same fix as was done for arm64 in r365578. Reviewed by: mhorne, imp Approved by: mhorne, imp Differential Revision:https://reviews.freebsd.org/D27603 Modified: head/stand/efi/loader/arch/riscv/ldscript.riscv Modified: head/stand/efi/loader/arch/riscv/ldscript.riscv == --- head/stand/efi/loader/arch/riscv/ldscript.riscv Mon Dec 14 00:50:45 2020(r368625) +++ head/stand/efi/loader/arch/riscv/ldscript.riscv Mon Dec 14 00:54:05 2020(r368626) @@ -82,6 +82,7 @@ SECTIONS _edata = .; /* Unused sections */ + .interp : { *(.interp) } .dynstr : { *(.dynstr) } .hash: { *(.hash) } } ___ 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"