From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by gnuweeb.org (Postfix) with ESMTPSA id 2E1A37EDA5 for ; Tue, 1 Mar 2022 11:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1646134448; bh=wMwH0Esa7+9XDQnRseGQt8XVBoPkgTDDTk0Y4Mory9w=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ozNH5t1JqCXZkK+2cROun6P2rSOAmspGKECltAFEdVniA8sbDxBzMgW9oPNrpGbh1 NzNz/TGh51LiBjUbwxMk2BAGleNmweGzvJtzI5rjcyW9hJNzJtnuI9g4+MDq2FZ5Vo rgTlebg9O99wGVDzAEBeeeAo+j5Rz07B5wdCfpk+Oa6zAAgpGx8mNgxkV/YhPicZaM cn/02HjPudmVAufa15GpcnRKYf4oERNNDAA9eUpyKIO+ePrWCAPMNgSXq7MefOFk9m jk+NmDVNv+zkyYKXul9xoMT5pad3v5vz3wDl5qSaQb16gkihZtgm00mJboSlrR0kcJ iu+wAfbinm4qw== Received: by mail-lf1-f50.google.com with SMTP id g39so26280937lfv.10 for ; Tue, 01 Mar 2022 03:34:08 -0800 (PST) X-Gm-Message-State: AOAM5312/dQoSiKASM9vHAFBq0oTnWOkHwwwb/U4RRDziuVs/OescvQt sU8MfImnVPvUKqGviGlHgizPIdtCzXR3MkavpFc= X-Google-Smtp-Source: ABdhPJx/og7d59BUuP9SzoT81fyxcdFHHXnA6Zmocol8wG52eI7x4l9kVQJ+3a3dLhPtZKivoBAxuF+VBA9iz/o4cMQ= X-Received: by 2002:a05:6512:1190:b0:443:ff19:e685 with SMTP id g16-20020a056512119000b00443ff19e685mr14888853lfr.70.1646134446046; Tue, 01 Mar 2022 03:34:06 -0800 (PST) MIME-Version: 1.0 References: <20220301094608.118879-1-ammarfaizi2@gnuweeb.org> <20220301094608.118879-2-ammarfaizi2@gnuweeb.org> In-Reply-To: <20220301094608.118879-2-ammarfaizi2@gnuweeb.org> From: Alviro Iskandar Setiawan Date: Tue, 1 Mar 2022 18:33:54 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/2] x86/delay: Fix the wrong asm constraint in `delay_loop()` To: Ammar Faizi 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 Content-Type: text/plain; charset="UTF-8" List-Id: On Tue, Mar 1, 2022 at 4:46 PM Ammar Faizi wrote: > Fortunately, the constraint violation that's fixed by patch 1 doesn't > yield any bug due to the nature of System V ABI. Should we backport > this? 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 -- Viro