From owner-svn-src-all@freebsd.org Sun Jul 29 22:32:10 2018 Return-Path: Delivered-To: svn-src-all@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 3825A10658C8; Sun, 29 Jul 2018 22:32:10 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B60B7D0D5; Sun, 29 Jul 2018 22:32:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w6TMVwuN070784 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 30 Jul 2018 01:32:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w6TMVwuN070784 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w6TMVwsq070783; Mon, 30 Jul 2018 01:31:58 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 30 Jul 2018 01:31:58 +0300 From: Konstantin Belousov To: Oliver Pinter Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r336876 - in head/sys: amd64/amd64 amd64/ia32 amd64/include conf dev/hyperv/vmbus/amd64 Message-ID: <20180729223158.GL40119@kib.kiev.ua> References: <201807292047.w6TKl0hV004691@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jul 2018 22:32:10 -0000 Please trim useless content. Did I missed anything interesting in your mail ? On Sun, Jul 29, 2018 at 11:57:47PM +0200, Oliver Pinter wrote: > On 7/29/18, Konstantin Belousov wrote: > > +ENTRY(copyin_smap) > > + PUSH_FRAME_POINTER > > + movq PCPU(CURPCB),%rax > > + movq $copyin_fault,PCB_ONFAULT(%rax) > > + testq %rdx,%rdx /* anything to do? */ > > + jz done_copyin > > + > > + /* > > + * make sure address is valid > > + */ > > + movq %rdi,%rax > > + addq %rdx,%rax > > + jc copyin_fault > > + movq $VM_MAXUSER_ADDRESS,%rcx > > + cmpq %rcx,%rax > > + ja copyin_fault > > + > > + xchgq %rdi,%rsi > > + movq %rdx,%rcx > > + movb %cl,%al > > + shrq $3,%rcx /* copy longword-wise */ > > missing cld from here In fact not. It is copyin_nosmap that got unneeded cld. See r327820, apparently I mis-merged this commit into the SMAP branch. > > > + stac > > + rep > > + movsq > > + movb %al,%cl > > + andb $7,%cl /* copy remaining bytes */ > > je done_copyin > > rep > > movsb > > + clac > > +ENTRY(copyinstr_smap) > > + PUSH_FRAME_POINTER > > + movq %rdx,%r8 /* %r8 = maxlen */ > > + movq %rcx,%r9 /* %r9 = *len */ > > + xchgq %rdi,%rsi /* %rdi = from, %rsi = to */ > > + movq PCPU(CURPCB),%rcx > > + movq $cpystrflt,PCB_ONFAULT(%rcx) > > + > > + movq $VM_MAXUSER_ADDRESS,%rax > > + > > + /* make sure 'from' is within bounds */ > > + subq %rsi,%rax > > + jbe cpystrflt > > + > > + /* restrict maxlen to <= VM_MAXUSER_ADDRESS-from */ > > + cmpq %rdx,%rax > > + jae 1f > > + movq %rax,%rdx > > + movq %rax,%r8 > > +1: > > + incq %rdx > > missing cld here Same. > > > + > > +2: > > + decq %rdx > > + jz copyinstr_succ > > cpystrflt_x: > /* set *lencopied and return %eax */ > movq PCPU(CURPCB),%rcx > movq $0,PCB_ONFAULT(%rcx) > > testq %r9,%r9 > jz 1f > subq %rdx,%r8 > movq %r8,(%r9) << Here you access user-space, with cleared > RFLAGS.AC from the fault handler. How does this instruction access userspace ? I do not see. > 1: > POP_FRAME_POINTER > ret So the patch below removes unneeded (mismerged) cld's left in the support.S. diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index 9b8b2a40461..0aa307e6895 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -307,7 +307,6 @@ ENTRY(copyout_smap) movq %rdx,%rcx shrq $3,%rcx - cld stac rep movsq @@ -358,7 +357,6 @@ ENTRY(copyin_nosmap) movq %rdx,%rcx movb %cl,%al shrq $3,%rcx /* copy longword-wise */ - cld rep movsq movb %al,%cl @@ -887,7 +885,6 @@ ENTRY(copyinstr_nosmap) movq %rax,%r8 1: incq %rdx - cld 2: decq %rdx