svn commit: r339352 - head

2018-10-13 Thread Ed Maste
Author: emaste
Date: Sun Oct 14 00:29:57 2018
New Revision: 339352
URL: https://svnweb.freebsd.org/changeset/base/339352

Log:
  Makefile.inc1: clean up dependencies after r339348
  
  r339348 switched bcopy from .s to .c.  Add ad-hoc dependency cleanup
  as done for similar cases.
  
  Approved by:  re (kib)
  Sponsored by: The FreeBSD Foundation

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Sat Oct 13 23:52:55 2018(r339351)
+++ head/Makefile.inc1  Sun Oct 14 00:29:57 2018(r339352)
@@ -939,6 +939,15 @@ _cleanobj_fast_depend_hack: .PHONY
${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
fi
 .endfor
+# 20181013  r339348  bcopy reimplemented as .c
+.for f in bcopy memcpy memmove
+   @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \
+   egrep -qw 'bcopy\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \
+   echo "Removing stale dependencies for bcopy"; \
+   rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
+  ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
+   fi
+.endfor
 # 20181009 track migration from ntp's embedded libevent to updated one
@if [ -e 
"${OBJTOP}/usr.sbin/ntp/libntpevent/.depend.bufferevent_openssl.o" ] && \
egrep -q 'contrib/ntp/sntp/libevent/bufferevent_openssl.c' \
___
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: r339351 - in head/lib/csu: aarch64 amd64 arm common i386 mips powerpc powerpc64 riscv sparc64

2018-10-13 Thread Konstantin Belousov
Author: kib
Date: Sat Oct 13 23:52:55 2018
New Revision: 339351
URL: https://svnweb.freebsd.org/changeset/base/339351

Log:
  Process irelocs for statically linked binaries from crt1 on x86.
  
  This makes statically linked binaries with ifuncs operational.
  
  Reported and tested by:   mjg
  Reviewed by:  emaste, markj
  Sponsored by: The FreeBSD Foundation
  Approved by:  re (rgrimes)
  Differential revision:https://reviews.freebsd.org/D17363

Added:
  head/lib/csu/amd64/reloc.c   (contents, props changed)
  head/lib/csu/i386/reloc.c   (contents, props changed)
Modified:
  head/lib/csu/aarch64/Makefile
  head/lib/csu/amd64/Makefile
  head/lib/csu/amd64/crt1.c
  head/lib/csu/arm/Makefile
  head/lib/csu/common/ignore_init.c
  head/lib/csu/i386/Makefile
  head/lib/csu/i386/crt1_c.c
  head/lib/csu/mips/Makefile
  head/lib/csu/powerpc/Makefile
  head/lib/csu/powerpc64/Makefile
  head/lib/csu/riscv/Makefile
  head/lib/csu/sparc64/Makefile

Modified: head/lib/csu/aarch64/Makefile
==
--- head/lib/csu/aarch64/Makefile   Sat Oct 13 21:26:07 2018
(r339350)
+++ head/lib/csu/aarch64/Makefile   Sat Oct 13 23:52:55 2018
(r339351)
@@ -7,6 +7,7 @@ OBJS=   ${SRCS:N*.h:R:S/$/.o/g}
 OBJS+= Scrt1.o gcrt1.o
 CFLAGS+=   -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
+CFLAGS+=   -DCRT_IRELOC_SUPPRESS
 
 FILES= ${OBJS}
 FILESMODE= ${LIBMODE}

Modified: head/lib/csu/amd64/Makefile
==
--- head/lib/csu/amd64/Makefile Sat Oct 13 21:26:07 2018(r339350)
+++ head/lib/csu/amd64/Makefile Sat Oct 13 23:52:55 2018(r339351)
@@ -5,9 +5,9 @@
 SRCS=  crt1.c crti.S crtn.S
 OBJS=  ${SRCS:N*.h:R:S/$/.o/g}
 OBJS+= Scrt1.o gcrt1.o
-CFLAGS+=   -I${.CURDIR:H}/common \
+CFLAGS+=   -I${.CURDIR} -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
-CFLAGS+=   -fno-omit-frame-pointer
+CFLAGS+=   -fno-omit-frame-pointer -DCRT_IRELOC_RELA
 
 FILES= ${OBJS}
 FILESMODE= ${LIBMODE}

Modified: head/lib/csu/amd64/crt1.c
==
--- head/lib/csu/amd64/crt1.c   Sat Oct 13 21:26:07 2018(r339350)
+++ head/lib/csu/amd64/crt1.c   Sat Oct 13 23:52:55 2018(r339351)
@@ -59,10 +59,12 @@ _start(char **ap, void (*cleanup)(void))
env = ap + 2 + argc;
handle_argv(argc, argv, env);
 
-   if (&_DYNAMIC != NULL)
+   if (&_DYNAMIC != NULL) {
atexit(cleanup);
-   else
+   } else {
+   process_irelocs();
_init_tls();
+   }
 
 #ifdef GCRT
atexit(_mcleanup);

Added: head/lib/csu/amd64/reloc.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/csu/amd64/reloc.c  Sat Oct 13 23:52:55 2018(r339351)
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+static void
+crt1_handle_rela(const Elf_Rela *r)
+{
+   Elf_Addr *ptr, *where, target;
+   u_int p[4];
+   uint32_t cpu_feature, cpu_feature2;
+   uint32_t cpu_stdext_feature, cpu_stdext_feature2;
+
+   do_cpuid(1, p);
+   cpu_feature = p[3];
+   cpu_feature2 = p[2];
+   do_cpuid(0, p);
+   if (p[0] >= 7) {
+   

svn commit: r339350 - head/contrib/elftoolchain/elfcopy

2018-10-13 Thread Ed Maste
Author: emaste
Date: Sat Oct 13 21:26:07 2018
New Revision: 339350
URL: https://svnweb.freebsd.org/changeset/base/339350

Log:
  elfcopy: delete filter_reloc, it is broken and unnecessary
  
  elfcopy contained logic to filter individual relocations in STRIP_ALL
  mode.  However, this is not valid; relocations emitted by the linker are
  required, unless they apply to an entire section being removed (which is
  handled by other logic in elfcopy).
  
  Note that filter_reloc was also buggy: for RELA relocation sections it
  operated on uninitialized rel.r_info resulting in invalid operation.
  
  The logic most likely needs to be inverted: instead of removing
  relocations because their associated symbols are being removed, we must
  keep symbols referenced by relocations.  That said, in practice we do
  not encounter this code path today: objects being stripped are either
  dynamically linked binaries which retain .dynsym, or static binaries
  with no relocations.
  
  Just remove filter_reloc.  This fixes certain cases including statically
  linked binaries containing ifuncs.  Stripping binaries with relocations
  referencing removed symbols was already broken, and after this change
  may still be broken in a different way.
  
  PR:   232176
  Reviewed by:  kaiw, kib, markj
  Approved by:  re (rgrimes)
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D17519

Modified:
  head/contrib/elftoolchain/elfcopy/sections.c

Modified: head/contrib/elftoolchain/elfcopy/sections.c
==
--- head/contrib/elftoolchain/elfcopy/sections.cSat Oct 13 21:18:31 
2018(r339349)
+++ head/contrib/elftoolchain/elfcopy/sections.cSat Oct 13 21:26:07 
2018(r339350)
@@ -39,7 +39,6 @@ ELFTC_VCSID("$Id: sections.c 3443 2016-04-15 18:57:54Z
 static voidadd_gnu_debuglink(struct elfcopy *ecp);
 static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc);
 static voidcheck_section_rename(struct elfcopy *ecp, struct section *s);
-static voidfilter_reloc(struct elfcopy *ecp, struct section *s);
 static int get_section_flags(struct elfcopy *ecp, const char *name);
 static voidinsert_sections(struct elfcopy *ecp);
 static voidinsert_to_strtab(struct section *t, const char *s);
@@ -574,14 +573,6 @@ copy_content(struct elfcopy *ecp)
continue;
 
/*
-* If strip action is STRIP_ALL, relocation info need
-* to be stripped. Skip filtering otherwisw.
-*/
-   if (ecp->strip == STRIP_ALL &&
-   (s->type == SHT_REL || s->type == SHT_RELA))
-   filter_reloc(ecp, s);
-
-   /*
 * The section indices in the SHT_GROUP section needs
 * to be updated since we might have stripped some
 * sections and changed section numbering.
@@ -670,125 +661,6 @@ update_section_group(struct elfcopy *ecp, struct secti
s->sz -= 4;
}
 
-   s->nocopy = 1;
-}
-
-/*
- * Filter relocation entries, only keep those entries whose
- * symbol is in the keep list.
- */
-static void
-filter_reloc(struct elfcopy *ecp, struct section *s)
-{
-   const char  *name;
-   GElf_Shdrish;
-   GElf_Rel rel;
-   GElf_Relarela;
-   Elf32_Rel   *rel32;
-   Elf64_Rel   *rel64;
-   Elf32_Rela  *rela32;
-   Elf64_Rela  *rela64;
-   Elf_Data*id;
-   uint64_t cap, n, nrels;
-   int  elferr, i;
-
-   if (gelf_getshdr(s->is, ) == NULL)
-   errx(EXIT_FAILURE, "gelf_getehdr() failed: %s",
-   elf_errmsg(-1));
-
-   /* We don't want to touch relocation info for dynamic symbols. */
-   if ((ecp->flags & SYMTAB_EXIST) == 0) {
-   if (ish.sh_link == 0 || ecp->secndx[ish.sh_link] == 0) {
-   /*
-* This reloc section applies to the symbol table
-* that was stripped, so discard whole section.
-*/
-   s->nocopy = 1;
-   s->sz = 0;
-   }
-   return;
-   } else {
-   /* Symbol table exist, check if index equals. */
-   if (ish.sh_link != elf_ndxscn(ecp->symtab->is))
-   return;
-   }
-
-#defineCOPYREL(REL, SZ) do {   \
-   if (nrels == 0) {   \
-   if ((REL##SZ = malloc(cap * \
-   sizeof(*REL##SZ))) == NULL) \
-   err(EXIT_FAILURE, "malloc failed"); \
-   }   \
-   if (nrels >= cap) {   

svn commit: r339348 - head/lib/libc/amd64/string

2018-10-13 Thread Mateusz Guzik
Author: mjg
Date: Sat Oct 13 21:17:28 2018
New Revision: 339348
URL: https://svnweb.freebsd.org/changeset/base/339348

Log:
  amd64: convert libc bcopy to a C func to avoid future bloat
  
  The function is of limited use and is an almost a direct clone of
  memmove/memcpy (with arguments swapped). Introduction of ERMS variants
  of string routines would mean avoidable growth of libc.
  
  bcopy will get redefined to a __builtin_memmove later on with this
  symbol only left for compatibility.
  
  Reviewed by:  kib
  Approved by:  re (gjb)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D17539

Added:
  head/lib/libc/amd64/string/bcopy.c   (contents, props changed)
Deleted:
  head/lib/libc/amd64/string/bcopy.S
Modified:
  head/lib/libc/amd64/string/Makefile.inc

Modified: head/lib/libc/amd64/string/Makefile.inc
==
--- head/lib/libc/amd64/string/Makefile.inc Sat Oct 13 21:15:47 2018
(r339347)
+++ head/lib/libc/amd64/string/Makefile.inc Sat Oct 13 21:17:28 2018
(r339348)
@@ -2,7 +2,6 @@
 
 MDSRCS+= \
bcmp.S \
-   bcopy.S \
bzero.S \
memcmp.S \
memcpy.S \

Added: head/lib/libc/amd64/string/bcopy.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/amd64/string/bcopy.c  Sat Oct 13 21:17:28 2018
(r339348)
@@ -0,0 +1,15 @@
+/*-
+ * Public domain.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+
+void
+bcopy(const void *src, void *dst, size_t len)
+{
+
+   memmove(dst, src, len);
+}
___
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: r339349 - in head/sys/amd64: amd64 include

2018-10-13 Thread Mateusz Guzik
Author: mjg
Date: Sat Oct 13 21:18:31 2018
New Revision: 339349
URL: https://svnweb.freebsd.org/changeset/base/339349

Log:
  amd64: partially depessimize cpu_fetch_syscall_args and cpu_set_syscall_retval
  
  Vast majority of syscalls take 6 or less arguments. Move handling of other
  cases to a fallback function. Similarly, special casing for _syscall
  and __syscall
  magic syscalls is moved away.
  
  Return is almost always 0. The change replaces 3 branches with 1 in the common
  case. Also the 'frame' variable convinces clang not to reload it on each 
access.
  
  Reviewed by:  kib
  Approved by:  re (gjb)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D17542

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/amd64/include/proc.h

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Sat Oct 13 21:17:28 2018(r339348)
+++ head/sys/amd64/amd64/trap.c Sat Oct 13 21:18:31 2018(r339349)
@@ -970,21 +970,19 @@ dblfault_handler(struct trapframe *frame)
panic("double fault");
 }
 
-int
-cpu_fetch_syscall_args(struct thread *td)
+static int __noinline
+cpu_fetch_syscall_args_fallback(struct thread *td, struct syscall_args *sa)
 {
struct proc *p;
struct trapframe *frame;
register_t *argp;
-   struct syscall_args *sa;
caddr_t params;
int reg, regcnt, error;
 
p = td->td_proc;
frame = td->td_frame;
-   sa = >td_sa;
reg = 0;
-   regcnt = 6;
+   regcnt = NARGREGS;
 
sa->code = frame->tf_rax;
 
@@ -1002,24 +1000,58 @@ cpu_fetch_syscall_args(struct thread *td)
sa->callp = >p_sysent->sv_table[sa->code];
 
sa->narg = sa->callp->sy_narg;
-   KASSERT(sa->narg <= sizeof(sa->args) / sizeof(sa->args[0]),
-   ("Too many syscall arguments!"));
-   error = 0;
+   KASSERT(sa->narg <= nitems(sa->args), ("Too many syscall arguments!"));
argp = >tf_rdi;
argp += reg;
-   memcpy(sa->args, argp, sizeof(sa->args[0]) * 6);
+   memcpy(sa->args, argp, sizeof(sa->args[0]) * NARGREGS);
if (sa->narg > regcnt) {
params = (caddr_t)frame->tf_rsp + sizeof(register_t);
error = copyin(params, >args[regcnt],
(sa->narg - regcnt) * sizeof(sa->args[0]));
+   if (__predict_false(error != 0))
+   return (error);
}
 
-   if (error == 0) {
-   td->td_retval[0] = 0;
-   td->td_retval[1] = frame->tf_rdx;
-   }
+   td->td_retval[0] = 0;
+   td->td_retval[1] = frame->tf_rdx;
 
-   return (error);
+   return (0);
+}
+
+int
+cpu_fetch_syscall_args(struct thread *td)
+{
+   struct proc *p;
+   struct trapframe *frame;
+   struct syscall_args *sa;
+
+   p = td->td_proc;
+   frame = td->td_frame;
+   sa = >td_sa;
+
+   sa->code = frame->tf_rax;
+
+   if (__predict_false(sa->code == SYS_syscall ||
+   sa->code == SYS___syscall ||
+   sa->code >= p->p_sysent->sv_size))
+   return (cpu_fetch_syscall_args_fallback(td, sa));
+
+   sa->callp = >p_sysent->sv_table[sa->code];
+   sa->narg = sa->callp->sy_narg;
+   KASSERT(sa->narg <= nitems(sa->args), ("Too many syscall arguments!"));
+
+   if (p->p_sysent->sv_mask)
+   sa->code &= p->p_sysent->sv_mask;
+
+   if (__predict_false(sa->narg > NARGREGS))
+   return (cpu_fetch_syscall_args_fallback(td, sa));
+
+   memcpy(sa->args, >tf_rdi, sizeof(sa->args[0]) * NARGREGS);
+
+   td->td_retval[0] = 0;
+   td->td_retval[1] = frame->tf_rdx;
+
+   return (0);
 }
 
 #include "../../kern/subr_syscall.c"

Modified: head/sys/amd64/amd64/vm_machdep.c
==
--- head/sys/amd64/amd64/vm_machdep.c   Sat Oct 13 21:17:28 2018
(r339348)
+++ head/sys/amd64/amd64/vm_machdep.c   Sat Oct 13 21:18:31 2018
(r339349)
@@ -372,14 +372,17 @@ cpu_thread_free(struct thread *td)
 void
 cpu_set_syscall_retval(struct thread *td, int error)
 {
+   struct trapframe *frame;
 
-   switch (error) {
-   case 0:
-   td->td_frame->tf_rax = td->td_retval[0];
-   td->td_frame->tf_rdx = td->td_retval[1];
-   td->td_frame->tf_rflags &= ~PSL_C;
-   break;
+   frame = td->td_frame;
+   if (__predict_true(error == 0)) {
+   frame->tf_rax = td->td_retval[0];
+   frame->tf_rdx = td->td_retval[1];
+   frame->tf_rflags &= ~PSL_C;
+   return;
+   }
 
+   switch (error) {
case ERESTART:
/*
 * Reconstruct pc, we know that 'syscall' is 2 bytes,
@@ -393,8 +396,8 @@ cpu_set_syscall_retval(struct thread *td, int 

svn commit: r339347 - head/lib/libc/amd64/string

2018-10-13 Thread Mateusz Guzik
Author: mjg
Date: Sat Oct 13 21:15:47 2018
New Revision: 339347
URL: https://svnweb.freebsd.org/changeset/base/339347

Log:
  amd64: import updated kernel memmove to libc
  
  bcopy is left alone as it is expected to be converted to a C func.
  
  Due to header mess ALIGN_TEXT is temporarily defined explicitly in memmove.S
  
  Reviewed by:  kib
  Approved by:  re (gjb)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D17538

Modified:
  head/lib/libc/amd64/string/memcpy.S
  head/lib/libc/amd64/string/memmove.S

Modified: head/lib/libc/amd64/string/memcpy.S
==
--- head/lib/libc/amd64/string/memcpy.S Sat Oct 13 16:25:28 2018
(r339346)
+++ head/lib/libc/amd64/string/memcpy.S Sat Oct 13 21:15:47 2018
(r339347)
@@ -1,5 +1,5 @@
 /* $NetBSD: memcpy.S,v 1.1 2001/06/19 00:25:05 fvdl Exp $  */
 /* $FreeBSD$ */
 
-#define MEMCOPY
-#include "bcopy.S"
+#define MEMCPY
+#include "memmove.S"

Modified: head/lib/libc/amd64/string/memmove.S
==
--- head/lib/libc/amd64/string/memmove.SSat Oct 13 16:25:28 2018
(r339346)
+++ head/lib/libc/amd64/string/memmove.SSat Oct 13 21:15:47 2018
(r339347)
@@ -1,5 +1,270 @@
-/* $NetBSD: memmove.S,v 1.1 2001/06/19 00:25:05 fvdl Exp $ */
-/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * This software was developed by Mateusz Guzik 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
-#define MEMMOVE
-#include "bcopy.S"
+#include 
+__FBSDID("$FreeBSD$");
+
+#defineALIGN_TEXT  .p2align 4,0x90 /* 16-byte alignment, nop 
filled */
+
+/*
+ * memmove(dst, src, cnt)
+ * rdi, rsi, rdx
+ * Contains parts of bcopy written by:
+ *  w...@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
+ */
+
+/*
+ * Register state at entry is supposed to be as follows:
+ * rdi - destination
+ * rsi - source
+ * rdx - count
+ *
+ * The macro possibly clobbers the above and: rcx, r8.
+ * It does not clobber rax, r10 nor r11.
+ */
+.macro MEMMOVE erms overlap begin end
+   \begin
+.if \overlap == 1
+   movq%rdi,%r8
+   subq%rsi,%r8
+   cmpq%rcx,%r8/* overlapping && src < dst? */
+   jb  2f
+.endif
+
+   cmpq$32,%rcx
+   jb  1016f
+
+   cmpq$256,%rcx
+   ja  1256f
+
+1032:
+   movq(%rsi),%rdx
+   movq%rdx,(%rdi)
+   movq8(%rsi),%rdx
+   movq%rdx,8(%rdi)
+   movq16(%rsi),%rdx
+   movq%rdx,16(%rdi)
+   movq24(%rsi),%rdx
+   movq%rdx,24(%rdi)
+   leaq32(%rsi),%rsi
+   leaq32(%rdi),%rdi
+   subq$32,%rcx
+   cmpq$32,%rcx
+   jae 1032b
+   cmpb$0,%cl
+   jne 1016f
+   \end
+   ret
+   ALIGN_TEXT
+1016:
+   cmpb$16,%cl
+   jl  1008f
+   movq(%rsi),%rdx
+   movq%rdx,(%rdi)
+   movq8(%rsi),%rdx
+   movq%rdx,8(%rdi)
+   subb$16,%cl
+   jz  1000f
+   leaq16(%rsi),%rsi
+   leaq16(%rdi),%rdi
+1008:
+   cmpb$8,%cl
+   jl  1004f
+   movq(%rsi),%rdx
+   movq%rdx,(%rdi)
+   subb$8,%cl
+   jz  1000f
+   leaq8(%rsi),%rsi
+   leaq8(%rdi),%rdi
+1004:
+   cmpb$4,%cl
+   jl  1002f
+   movl(%rsi),%edx
+   movl%edx,(%rdi)
+   subb$4,%cl
+   jz  1000f
+   leaq4(%rsi),%rsi
+   leaq4(%rdi),%rdi
+1002:
+   cmpb$2,%cl
+   jl  

Re: svn commit: r339326 - head

2018-10-13 Thread Bryan Drewery
On 10/12/2018 4:33 AM, Kyle Evans wrote:
> On Fri, Oct 12, 2018 at 12:43 AM Dag-Erling Smørgrav  wrote:
>>
>> Author: des
>> Date: Fri Oct 12 05:42:38 2018
>> New Revision: 339326
>> URL: https://svnweb.freebsd.org/changeset/base/339326
>>
>> Log:
>>   Move libssl up in the bootstrap order.
>>
>>   Submitted by: jkim
>>   Approved by:  re (gjb)
>>
>> Modified:
>>   head/Makefile.inc1
>>
>> Modified: head/Makefile.inc1
>> ==
>> --- head/Makefile.inc1  Fri Oct 12 05:27:58 2018(r339325)
>> +++ head/Makefile.inc1  Fri Oct 12 05:42:38 2018(r339326)
>> @@ -2534,8 +2534,8 @@ _prebuild_libs=   ${_kerberos5_lib_libasn1} \
>> ${_cddl_lib_libctf} \
>> lib/libufs \
>> lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz 
>> lib/msun \
>> -   ${_secure_lib_libcrypto} ${_lib_libldns} \
>> -   ${_secure_lib_libssh} ${_secure_lib_libssl}
>> +   ${_secure_lib_libcrypto} ${_secure_lib_libssl} \
>> +   ${_lib_libldns} ${_secure_lib_libssh}
>>
>>  .if ${MK_GNUCXX} != "no"
>>  _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
>> ___
> 
> Hmm... doesn't this kind of situation also require an __L rule down
> below to prevent the race, since they're both in prebuild_libs?
> 
> Thanks,
> 

Yes, this list is not an ordering. It's just a list. The ordering comes
from __L targets which define the dependency graph.


-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r339346 - head/lib/libc/stdtime

2018-10-13 Thread Yuri Pankov
Author: yuripv
Date: Sat Oct 13 16:25:28 2018
New Revision: 339346
URL: https://svnweb.freebsd.org/changeset/base/339346

Log:
  strptime: disallow zero hour for %I (defined by POSIX as [01,12]) and %l
  (extension, defined in strftime(3) as 1-12).
  
  Approved by:  re (gjb), kib (mentor)
  Differential Revision:https://reviews.freebsd.org/D17543

Modified:
  head/lib/libc/stdtime/strptime.c

Modified: head/lib/libc/stdtime/strptime.c
==
--- head/lib/libc/stdtime/strptime.cSat Oct 13 03:12:57 2018
(r339345)
+++ head/lib/libc/stdtime/strptime.cSat Oct 13 16:25:28 2018
(r339346)
@@ -291,7 +291,7 @@ label:
if (c == 'H' || c == 'k') {
if (i > 23)
return (NULL);
-   } else if (i > 12)
+   } else if (i == 0 || i > 12)
return (NULL);
 
tm->tm_hour = i;
___
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: r339344 - head/usr.sbin/mfiutil

2018-10-13 Thread Allan Jude
Author: allanjude
Date: Sat Oct 13 02:21:23 2018
New Revision: 339344
URL: https://svnweb.freebsd.org/changeset/base/339344

Log:
  Make `mfiutil show progress` print out the elapsed time estimate in a
  more humanized way
  
  PR:   225993
  Submitted by: Enji Cooper 
  Reviewed by:  jhb (previous version)
  Approved by:  re (rgrimes)

Modified:
  head/usr.sbin/mfiutil/mfi_cmd.c

Modified: head/usr.sbin/mfiutil/mfi_cmd.c
==
--- head/usr.sbin/mfiutil/mfi_cmd.c Sat Oct 13 02:20:16 2018
(r339343)
+++ head/usr.sbin/mfiutil/mfi_cmd.c Sat Oct 13 02:21:23 2018
(r339344)
@@ -31,17 +31,18 @@
  * $FreeBSD$
  */
 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "mfiutil.h"
@@ -311,24 +312,34 @@ mfi_open(int unit, int acs)
return (open(path, acs));
 }
 
+static void
+print_time_humanized(uint seconds)
+{
+
+   if (seconds > 3600) {
+   printf("%u:", seconds / 3600);
+   }
+   if (seconds > 60) {
+   seconds %= 3600;
+   printf("%02u:%02u", seconds / 60, seconds % 60);
+   } else {
+   printf("%us", seconds);
+   }
+}
+
 void
 mfi_display_progress(const char *label, struct mfi_progress *prog)
 {
uint seconds;
 
-   printf("%s: %.2f%% complete, after %ds", label,
-   (float)prog->progress * 100 / 0x, prog->elapsed_seconds);
+   printf("%s: %.2f%% complete after ", label,
+   (float)prog->progress * 100 / 0x);
+   print_time_humanized(prog->elapsed_seconds);
if (prog->progress != 0 && prog->elapsed_seconds > 10) {
printf(" finished in ");
seconds = (0x1 * (uint32_t)prog->elapsed_seconds) /
prog->progress - prog->elapsed_seconds;
-   if (seconds > 3600)
-   printf("%u:", seconds / 3600);
-   if (seconds > 60) {
-   seconds %= 3600;
-   printf("%02u:%02u", seconds / 60, seconds % 60);
-   } else
-   printf("%us", seconds);
+   print_time_humanized(seconds);
}
printf("\n");
 }
___
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"