From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [192.168.43.69] (unknown [182.2.41.243]) by gnuweeb.org (Postfix) with ESMTPSA id E76197E29A; Thu, 3 Mar 2022 00:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1646266023; bh=FXJ5RIO8Oqa50icw+tN38pTqQ1lL1MDXri2vESEbOg0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Qs9kOFlmA24f/j91hiJ5vZ3XiNoZkicH8EA217zJ1ThsXNvKfiiqjO7jYUumaa7bZ 8/H1DD9nGRCQUQtxXuWMDRO8pyV6jPga/5rXM6xOWVIfSdwY6xfzf3BPsDmR8bhJqj r1vIt6IKpd4bg6BbOZmYLO+J2y+J+SPtJ6f6tA4CneYu8CmiviamL/qocX7V4NgVmK T6HlKHPP7BApNnUeNaZJcy7aorzSN5XKQgcE1m3nGdxj1jgUJc3Pcc62v3lVZUFaPO ulS5kViDcEBZDYlGNUCLG2i0PIWua8fPKz8gZ+m4wS15XdA6sysccIAUZHPAuVIvSV Mf7KExPwK02Ew== Message-ID: <4f7d2b07-c5e5-33dc-f6a7-c62b1c5329b9@gnuweeb.org> Date: Thu, 3 Mar 2022 07:06:52 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 1/2] x86/delay: Fix the wrong asm constraint in `delay_loop()` Content-Language: en-US To: Alviro Iskandar Setiawan Cc: Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , Tony Luck , linux-edac@vger.kernel.org, Linux Kernel Mailing List , GNU/Weeb Mailing List , x86@kernel.org, stable@vger.kernel.org, Jiri Hladky , Greg Kroah-Hartman , David Laight References: <20220301094608.118879-1-ammarfaizi2@gnuweeb.org> <20220301094608.118879-2-ammarfaizi2@gnuweeb.org> From: Ammar Faizi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: On 3/1/22 6:33 PM, Alviro Iskandar Setiawan wrote: > hi sir, it might also be interesting to know that even if it never be > inlined, it's still potential to break. > > for example this code (https://godbolt.org/z/xWMTxhTET) > > __attribute__((__noinline__)) static void x(int a) > { > asm("xorl\t%%r8d, %%r8d"::"a"(a)); > } > > extern int p(void); > > int f(void) > { > int ret = p(); > x(ret); > return ret; > } > > translates to this asm > > x: > movl %edi, %eax > xorl %r8d, %r8d > ret > f: > subq $8, %rsp > call p > movl %eax, %r8d > movl %eax, %edi > call x > movl %r8d, %eax > addq $8, %rsp > ret > > See the %r8d? It should be clobbered by a function call too. But since > no one tells the compiler that we clobber %r8d, it assumes %r8d never > changes after that call. The compiler thinks x() is static and will > not clobber %r8d, even the ABI says %r8d will be clobbered by a > function call. So i think it should be backported to the stable > kernel, it's still a fix Thanks. I will add CC stable in the v5. -- Ammar Faizi