From owner-svn-src-head@freebsd.org Mon May 7 19:10:34 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF141FB9E23 for ; Mon, 7 May 2018 19:10:34 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-yb0-x244.google.com (mail-yb0-x244.google.com [IPv6:2607:f8b0:4002:c09::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3F40B7043F for ; Mon, 7 May 2018 19:10:34 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-yb0-x244.google.com with SMTP id i13-v6so10303736ybl.4 for ; Mon, 07 May 2018 12:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Cfa+KwMkb6iaiz56XxAwsfWZrZ+pvj1DlOQQwLGSsW0=; b=ly72l3LbnmX+VwsbPzspTMXUR0hErqNmIVN0bnYLiDBJLPKevnI1xvFusUZ+gpjExD s3YRYJ6htdRgBQfzB7e/3gbYxLJkF/PRCIwY0AdxJtfbJnJ4Pr+KTWmzIwP4wl4I/z+J vmyykTJISGEiUlmhwZliaNsn9xj1tXTOJRDgKh4oZ7ktVK62f8/54og74DZFRxoJIgiY UrVUVNySPHDC17cRY5Fxc6jrd14c6oCoUeMb93mX5EuQTljEGnJTlvMNfPKI6jBjzmUE KBlRvbVnkxLakhSto4rD94Rs4jfGT3rnuYUiB60rU/t/0GEV+jHeS4fDBIAPUg7xfmop AnkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Cfa+KwMkb6iaiz56XxAwsfWZrZ+pvj1DlOQQwLGSsW0=; b=cI16FuzRK+TIIpxHdNlbLMYUApkrx3nuBJNDsrHYU2UT7VGUYlKHMoSuAkxfOEm7Mq U94MKCRRWkxMzvNTq9gP9ISzzBjJs74Ap/VoewCMt34LG8vgBOM7RNipcjvF0vGasYb/ df9tr5+q6UjzVp0nuhbHtorQxVbkGLBpRYD8sGd8a0lYuukKiZoXDsInWlYGMjUTt5Rw VBkib7MlFr+ZS28eFkthy6ffT1LcPQBNKPiK1lfQxSyGbK3x+AIMUVwk2k1Od1NnlN/y GkpkrqBaMqgHa2Xv5/8QCJY0RjuYp+t3fmIQrnTanZMfl3vv4XpszY7XFn6APbku3nM5 IVVw== X-Gm-Message-State: ALKqPwcSNvNiOpXfGTzf5axb4zTpKWfGV1moT0T6sdT/i3m4n0nV4zxC m/V6Pj07taNdIlUckxwMdWGFNLis4f/fYoeMm/qVoA== X-Google-Smtp-Source: AB8JxZoOo2OCJ7drcf7J+YZyboXJAGy276BvdmrdK27MjirSTJ1HocmrLvYAezzg9Su68u3W9VUP7cPzRmUhQrOU2TM= X-Received: by 2002:a25:8746:: with SMTP id e6-v6mr681501ybn.371.1525720233743; Mon, 07 May 2018 12:10:33 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:3894:0:0:0:0:0 with HTTP; Mon, 7 May 2018 12:10:33 -0700 (PDT) In-Reply-To: <201805071545.w47FjZYA056520@pdx.rh.CN85.dnsmgr.net> References: <201805071507.w47F7SOs035073@repo.freebsd.org> <201805071545.w47FjZYA056520@pdx.rh.CN85.dnsmgr.net> From: Oliver Pinter Date: Mon, 7 May 2018 21:10:33 +0200 Message-ID: Subject: Re: svn commit: r333324 - in head/sys: amd64/amd64 conf To: rgrimes@freebsd.org Cc: Mateusz Guzik , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 May 2018 19:10:35 -0000 On 5/7/18, Rodney W. Grimes wrote: >> Author: mjg >> Date: Mon May 7 15:07:28 2018 >> New Revision: 333324 >> URL: https://svnweb.freebsd.org/changeset/base/333324 >> >> Log: >> amd64: replace libkern's memset and memmove with assembly variants >> >> memmove is repurposed bcopy (arguments swapped, return value added) >> The libkern variant is a wrapper around bcopy, so this is a big >> improvement. >> >> memset is repurposed memcpy. The librkern variant is doing fishy stuff, >> including branching on 0 and calling bzero. >> >> Both functions are rather crude and subject to partial depessimization. >> >> This is a soft prerequisite to adding variants utilizing the >> 'Enhanced REP MOVSB/STOSB' bit and let the kernel patch at runtime. >> >> Modified: >> head/sys/amd64/amd64/support.S >> head/sys/conf/files.amd64 >> >> Modified: head/sys/amd64/amd64/support.S >> ============================================================================== >> --- head/sys/amd64/amd64/support.S Mon May 7 15:07:26 2018 (r333323) >> +++ head/sys/amd64/amd64/support.S Mon May 7 15:07:28 2018 (r333324) >> @@ -162,6 +162,58 @@ ENTRY(bcopy) >> END(bcopy) >> >> /* >> + * memmove(dst, src, cnt) >> + * rdi, rsi, rdx >> + * Original by: >> + * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 > > If the original is by ws@tools.de, who is this version by? > Or is this simply copied from some other FreeBSD file? Btw, it would be much better to review the relevant and function parts of the codes, rather than mocking with comments. ;) // not limited to this patch > > Thanks, >> + */ >> +ENTRY(memmove) >> + PUSH_FRAME_POINTER >> + movq %rdi,%r9 >> + movq %rdx,%rcx >> + >> + movq %rdi,%rax >> + subq %rsi,%rax >> + cmpq %rcx,%rax /* overlapping && src < dst? */ >> + jb 1f >> + >> + shrq $3,%rcx /* copy by 64-bit words */ >> + rep >> + movsq >> + movq %rdx,%rcx >> + andq $7,%rcx /* any bytes left? */ >> + rep >> + movsb >> + movq %r9,%rax >> + POP_FRAME_POINTER >> + ret >> + >> + /* ALIGN_TEXT */ >> +1: >> + addq %rcx,%rdi /* copy backwards */ >> + addq %rcx,%rsi >> + decq %rdi >> + decq %rsi >> + andq $7,%rcx /* any fractional bytes? */ >> + std >> + rep >> + movsb >> + movq %rdx,%rcx /* copy remainder by 32-bit words */ >> + shrq $3,%rcx >> + subq $7,%rsi >> + subq $7,%rdi >> + rep >> + movsq >> + cld >> + movq %r9,%rax >> + POP_FRAME_POINTER >> + ret >> +END(memmove) >> + >> +/* >> + * memcpy(dst, src, len) >> + * rdi, rsi, rdx >> + * >> * Note: memcpy does not support overlapping copies >> */ >> ENTRY(memcpy) >> @@ -178,6 +230,27 @@ ENTRY(memcpy) >> POP_FRAME_POINTER >> ret >> END(memcpy) >> + >> +/* >> + * memset(dst, c, len) >> + * rdi, rsi, rdx >> + */ >> +ENTRY(memset) >> + PUSH_FRAME_POINTER >> + movq %rdi,%r9 >> + movq %rdx,%rcx >> + movq %rsi,%rax >> + shrq $3,%rcx >> + rep >> + stosq >> + movq %rdx,%rcx >> + andq $7,%rcx >> + rep >> + stosb >> + movq %r9,%rax >> + POP_FRAME_POINTER >> + ret >> +END(memset) >> >> /* >> * pagecopy(%rdi=from, %rsi=to) >> >> Modified: head/sys/conf/files.amd64 >> ============================================================================== >> --- head/sys/conf/files.amd64 Mon May 7 15:07:26 2018 (r333323) >> +++ head/sys/conf/files.amd64 Mon May 7 15:07:28 2018 (r333324) >> @@ -620,8 +620,6 @@ isa/vga_isa.c optional vga >> kern/kern_clocksource.c standard >> kern/link_elf_obj.c standard >> libkern/x86/crc32_sse42.c standard >> -libkern/memmove.c standard >> -libkern/memset.c standard >> # >> # IA32 binary support >> # >> >> > > -- > Rod Grimes > rgrimes@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-unsubscribe@freebsd.org" >