From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx130.postini.com [74.125.245.130]) by kanga.kvack.org (Postfix) with SMTP id 7A3886B004F for ; Sat, 17 Dec 2011 09:52:35 -0500 (EST) Received: by iacb35 with SMTP id b35so5406171iac.14 for ; Sat, 17 Dec 2011 06:52:34 -0800 (PST) From: Nai Xia Reply-To: nai.xia@gmail.com Subject: Question about missing "cld" in x86 string assembly code Date: Sat, 17 Dec 2011 22:52:26 +0800 MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201112172252.26439.nai.xia@gmail.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andi Kleen Cc: Linus Torvalds , Linux-MM , LKML Hi, I notice that all x86 assembly code for string operations containing "scasb, lodsb", etc does not have "cld" at the beginning. Is this 100% safe? Or in other words, how could we be sure that there is no "std" generated by compiler somewhere just before the string operations? Thanks, Nai -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx162.postini.com [74.125.245.162]) by kanga.kvack.org (Postfix) with SMTP id 9E00A6B004F for ; Sat, 17 Dec 2011 09:58:32 -0500 (EST) Received: by iacb35 with SMTP id b35so5413744iac.14 for ; Sat, 17 Dec 2011 06:58:32 -0800 (PST) From: Nai Xia Reply-To: nai.xia@gmail.com Subject: Question about missing "cld" in x86 string assembly code Date: Sat, 17 Dec 2011 22:58:24 +0800 MIME-Version: 1.0 Message-Id: <201112172258.24221.nai.xia@gmail.com> Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Andi Kleen Cc: Linus Torvalds , Linux-MM , LKML Hi Andi, Seems I used a stale email address of you from a related git commit log, so this is a resend, sorry. ======= Hi, I notice that all x86 assembly code for string operations containing "scasb, lodsb", etc does not have "cld" at the beginning. Is this 100% safe? Or in other words, how could we be sure that there is no "std" generated by compiler somewhere just before the string operations? Thanks, Nai -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx207.postini.com [74.125.245.207]) by kanga.kvack.org (Postfix) with SMTP id A342E6B004F for ; Sat, 17 Dec 2011 12:08:38 -0500 (EST) Received: by wibhq12 with SMTP id hq12so609738wib.14 for ; Sat, 17 Dec 2011 09:08:36 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <201112172258.24221.nai.xia@gmail.com> References: <201112172258.24221.nai.xia@gmail.com> Date: Sat, 17 Dec 2011 12:08:36 -0500 Message-ID: Subject: Re: Question about missing "cld" in x86 string assembly code From: Brian Gerst Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: nai.xia@gmail.com Cc: Andi Kleen , Linus Torvalds , Linux-MM , LKML On Sat, Dec 17, 2011 at 9:58 AM, Nai Xia wrote: > Hi Andi, > > Seems I used a stale email address of you from a related git commit log, > so this is a resend, sorry. > > =3D=3D=3D=3D=3D=3D=3D > Hi, > > I notice that all x86 assembly code for string operations containing > "scasb, lodsb", etc does not have "cld" at the beginning. > Is this 100% safe? > Or in other words, how could we be sure that > there is no "std" generated by compiler somewhere just before > the string operations? > > > Thanks, > > Nai > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" i= n > the body of a message to majordomo@vger.kernel.org > More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.html > Please read the FAQ at =C2=A0http://www.tux.org/lkml/ The i386 ELF ABI states "The direction flag must be set to the =E2=80=98=E2=80=98forward=E2=80=99=E2=80=99 (that is, zero) direction befor= e entry and upon exit from a function." Therefore it can be assumed to be clear, unless explicitly set. -- Brian Gerst -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx168.postini.com [74.125.245.168]) by kanga.kvack.org (Postfix) with SMTP id 3CFB76B004F for ; Sat, 17 Dec 2011 13:39:26 -0500 (EST) Received: by wgbds13 with SMTP id ds13so6912179wgb.26 for ; Sat, 17 Dec 2011 10:39:24 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <201112172258.24221.nai.xia@gmail.com> From: Linus Torvalds Date: Sat, 17 Dec 2011 10:39:03 -0800 Message-ID: Subject: Re: Question about missing "cld" in x86 string assembly code Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Brian Gerst Cc: nai.xia@gmail.com, Andi Kleen , Linux-MM , LKML On Sat, Dec 17, 2011 at 9:08 AM, Brian Gerst wrote: > > The i386 ELF ABI states "The direction flag must be set to the > =91=91forward=92=92 (that is, zero) direction before entry and upon exit = from > a function." =A0Therefore it can be assumed to be clear, unless > explicitly set. The exception, of course, being bootup, fault and interrupt handlers, and after we've called out to foreign code (ie BIOS). So there *are* a few cld's sprinkled around, they are just fairly rare. Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx169.postini.com [74.125.245.169]) by kanga.kvack.org (Postfix) with SMTP id DCE736B004D for ; Thu, 22 Dec 2011 10:35:01 -0500 (EST) Received: by iacb35 with SMTP id b35so15464912iac.14 for ; Thu, 22 Dec 2011 07:35:01 -0800 (PST) Message-ID: <4EF34E1E.6000805@gmail.com> Date: Thu, 22 Dec 2011 23:34:54 +0800 From: "nai.xia" MIME-Version: 1.0 Subject: Re: Question about missing "cld" in x86 string assembly code References: <201112172258.24221.nai.xia@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: owner-linux-mm@kvack.org List-ID: To: Brian Gerst Cc: Andi Kleen , Linus Torvalds , Linux-MM , LKML On 2011a1'12ae??18ae?JPY 01:08, Brian Gerst wrote: > On Sat, Dec 17, 2011 at 9:58 AM, Nai Xia wrote: >> Hi Andi, >> >> Seems I used a stale email address of you from a related git commit log, >> so this is a resend, sorry. >> >> ======= >> Hi, >> >> I notice that all x86 assembly code for string operations containing >> "scasb, lodsb", etc does not have "cld" at the beginning. >> Is this 100% safe? >> Or in other words, how could we be sure that >> there is no "std" generated by compiler somewhere just before >> the string operations? >> >> >> Thanks, >> >> Nai >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Please read the FAQ at http://www.tux.org/lkml/ > > The i386 ELF ABI states "The direction flag must be set to the > a??a??forwarda??a?? (that is, zero) direction before entry and upon exit from > a function." Therefore it can be assumed to be clear, unless > explicitly set. Hmm, I get those lines now. Thanks for reply. Seems gcc started to strictly conform to this ABI since 4.3 . But glibc seems still have some leading "cld" string code, maybe just prepared for non-conforming kernels other than Linux. > > -- > Brian Gerst -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx150.postini.com [74.125.245.150]) by kanga.kvack.org (Postfix) with SMTP id 347B26B0068 for ; Thu, 22 Dec 2011 10:52:42 -0500 (EST) Received: by iacb35 with SMTP id b35so15491804iac.14 for ; Thu, 22 Dec 2011 07:52:41 -0800 (PST) Message-ID: <4EF35243.9030600@gmail.com> Date: Thu, 22 Dec 2011 23:52:35 +0800 From: "nai.xia" MIME-Version: 1.0 Subject: Re: Question about missing "cld" in x86 string assembly code References: <201112172258.24221.nai.xia@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: owner-linux-mm@kvack.org List-ID: To: Linus Torvalds Cc: Brian Gerst , Andi Kleen , Linux-MM , LKML On 2011a1'12ae??18ae?JPY 02:39, Linus Torvalds wrote: > On Sat, Dec 17, 2011 at 9:08 AM, Brian Gerst wrote: >> >> The i386 ELF ABI states "The direction flag must be set to the >> a??a??forwarda??a?? (that is, zero) direction before entry and upon exit from >> a function." Therefore it can be assumed to be clear, unless >> explicitly set. > > The exception, of course, being bootup, fault and interrupt handlers, > and after we've called out to foreign code (ie BIOS). Yeah, I think I see these cld's now. Thanks for the answers! Nai > > So there *are* a few cld's sprinkled around, they are just fairly rare. > > Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752382Ab1LQOwh (ORCPT ); Sat, 17 Dec 2011 09:52:37 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:38334 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752293Ab1LQOwf (ORCPT ); Sat, 17 Dec 2011 09:52:35 -0500 From: Nai Xia Reply-To: nai.xia@gmail.com To: Andi Kleen Subject: Question about missing "cld" in x86 string assembly code Date: Sat, 17 Dec 2011 22:52:26 +0800 User-Agent: KMail/1.13.6 (Linux/2.6.38-13-generic-pae-uksm; KDE/4.6.5; i686; ; ) Cc: Linus Torvalds , "Linux-MM" , LKML MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201112172252.26439.nai.xia@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I notice that all x86 assembly code for string operations containing "scasb, lodsb", etc does not have "cld" at the beginning. Is this 100% safe? Or in other words, how could we be sure that there is no "std" generated by compiler somewhere just before the string operations? Thanks, Nai From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752363Ab1LQO6e (ORCPT ); Sat, 17 Dec 2011 09:58:34 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:53897 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752149Ab1LQO6c (ORCPT ); Sat, 17 Dec 2011 09:58:32 -0500 From: Nai Xia Reply-To: nai.xia@gmail.com To: Andi Kleen Subject: Question about missing "cld" in x86 string assembly code Date: Sat, 17 Dec 2011 22:58:24 +0800 User-Agent: KMail/1.13.6 (Linux/2.6.38-13-generic-pae-uksm; KDE/4.6.5; i686; ; ) Cc: Linus Torvalds , "Linux-MM" , LKML MIME-Version: 1.0 Message-Id: <201112172258.24221.nai.xia@gmail.com> Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andi, Seems I used a stale email address of you from a related git commit log, so this is a resend, sorry. ======= Hi, I notice that all x86 assembly code for string operations containing "scasb, lodsb", etc does not have "cld" at the beginning. Is this 100% safe? Or in other words, how could we be sure that there is no "std" generated by compiler somewhere just before the string operations? Thanks, Nai From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752478Ab1LQRIk (ORCPT ); Sat, 17 Dec 2011 12:08:40 -0500 Received: from mail-ww0-f42.google.com ([74.125.82.42]:32910 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389Ab1LQRIi convert rfc822-to-8bit (ORCPT ); Sat, 17 Dec 2011 12:08:38 -0500 MIME-Version: 1.0 In-Reply-To: <201112172258.24221.nai.xia@gmail.com> References: <201112172258.24221.nai.xia@gmail.com> Date: Sat, 17 Dec 2011 12:08:36 -0500 Message-ID: Subject: Re: Question about missing "cld" in x86 string assembly code From: Brian Gerst To: nai.xia@gmail.com Cc: Andi Kleen , Linus Torvalds , Linux-MM , LKML Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 17, 2011 at 9:58 AM, Nai Xia wrote: > Hi Andi, > > Seems I used a stale email address of you from a related git commit log, > so this is a resend, sorry. > > ======= > Hi, > > I notice that all x86 assembly code for string operations containing > "scasb, lodsb", etc does not have "cld" at the beginning. > Is this 100% safe? > Or in other words, how could we be sure that > there is no "std" generated by compiler somewhere just before > the string operations? > > > Thanks, > > Nai > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at  http://vger.kernel.org/majordomo-info.html > Please read the FAQ at  http://www.tux.org/lkml/ The i386 ELF ABI states "The direction flag must be set to the ‘‘forward’’ (that is, zero) direction before entry and upon exit from a function." Therefore it can be assumed to be clear, unless explicitly set. -- Brian Gerst From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752673Ab1LQSj1 (ORCPT ); Sat, 17 Dec 2011 13:39:27 -0500 Received: from mail-ww0-f44.google.com ([74.125.82.44]:58286 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751398Ab1LQSjZ convert rfc822-to-8bit (ORCPT ); Sat, 17 Dec 2011 13:39:25 -0500 MIME-Version: 1.0 In-Reply-To: References: <201112172258.24221.nai.xia@gmail.com> From: Linus Torvalds Date: Sat, 17 Dec 2011 10:39:03 -0800 X-Google-Sender-Auth: 5V4PJFY880rbLZZDZyouFOS06J0 Message-ID: Subject: Re: Question about missing "cld" in x86 string assembly code To: Brian Gerst Cc: nai.xia@gmail.com, Andi Kleen , Linux-MM , LKML Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 17, 2011 at 9:08 AM, Brian Gerst wrote: > > The i386 ELF ABI states "The direction flag must be set to the > ‘‘forward’’ (that is, zero) direction before entry and upon exit from > a function."  Therefore it can be assumed to be clear, unless > explicitly set. The exception, of course, being bootup, fault and interrupt handlers, and after we've called out to foreign code (ie BIOS). So there *are* a few cld's sprinkled around, they are just fairly rare. Linus From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754283Ab1LVPfG (ORCPT ); Thu, 22 Dec 2011 10:35:06 -0500 Received: from mail-gx0-f174.google.com ([209.85.161.174]:59750 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753114Ab1LVPfC (ORCPT ); Thu, 22 Dec 2011 10:35:02 -0500 Message-ID: <4EF34E1E.6000805@gmail.com> Date: Thu, 22 Dec 2011 23:34:54 +0800 From: "nai.xia" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: Brian Gerst CC: Andi Kleen , Linus Torvalds , Linux-MM , LKML Subject: Re: Question about missing "cld" in x86 string assembly code References: <201112172258.24221.nai.xia@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2011å¹´12月18æ—¥ 01:08, Brian Gerst wrote: > On Sat, Dec 17, 2011 at 9:58 AM, Nai Xia wrote: >> Hi Andi, >> >> Seems I used a stale email address of you from a related git commit log, >> so this is a resend, sorry. >> >> ======= >> Hi, >> >> I notice that all x86 assembly code for string operations containing >> "scasb, lodsb", etc does not have "cld" at the beginning. >> Is this 100% safe? >> Or in other words, how could we be sure that >> there is no "std" generated by compiler somewhere just before >> the string operations? >> >> >> Thanks, >> >> Nai >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Please read the FAQ at http://www.tux.org/lkml/ > > The i386 ELF ABI states "The direction flag must be set to the > ‘‘forward’’ (that is, zero) direction before entry and upon exit from > a function." Therefore it can be assumed to be clear, unless > explicitly set. Hmm, I get those lines now. Thanks for reply. Seems gcc started to strictly conform to this ABI since 4.3 . But glibc seems still have some leading "cld" string code, maybe just prepared for non-conforming kernels other than Linux. > > -- > Brian Gerst From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755102Ab1LVPwq (ORCPT ); Thu, 22 Dec 2011 10:52:46 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:59585 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754115Ab1LVPwm (ORCPT ); Thu, 22 Dec 2011 10:52:42 -0500 Message-ID: <4EF35243.9030600@gmail.com> Date: Thu, 22 Dec 2011 23:52:35 +0800 From: "nai.xia" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: Linus Torvalds CC: Brian Gerst , Andi Kleen , Linux-MM , LKML Subject: Re: Question about missing "cld" in x86 string assembly code References: <201112172258.24221.nai.xia@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2011å¹´12月18æ—¥ 02:39, Linus Torvalds wrote: > On Sat, Dec 17, 2011 at 9:08 AM, Brian Gerst wrote: >> >> The i386 ELF ABI states "The direction flag must be set to the >> ‘‘forward’’ (that is, zero) direction before entry and upon exit from >> a function." Therefore it can be assumed to be clear, unless >> explicitly set. > > The exception, of course, being bootup, fault and interrupt handlers, > and after we've called out to foreign code (ie BIOS). Yeah, I think I see these cld's now. Thanks for the answers! Nai > > So there *are* a few cld's sprinkled around, they are just fairly rare. > > Linus