From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, T_SPF_HELO_TEMPERROR,T_SPF_TEMPERROR,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by gnuweeb.org (Postfix) with ESMTPS id 651087E2FD for ; Sun, 27 Mar 2022 21:38:53 +0000 (UTC) Received: from zn.tnic (p2e55dff8.dip0.t-ipconnect.de [46.85.223.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 39C331EC0445; Sun, 27 Mar 2022 23:38:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1648417127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=yY2YO2yI1wDQsqCh9TwGDSc6J5E2vMROt0/Y5L3W2YA=; b=Bd2NRiBlYU/7gjHBDaGDBMPmNPrj6YrgLnik0JFCUMNqqNsSF9qFQiyUx7qjqEHK3j8s39 B/qxAv/7yle1SEMTiVl887UXaAl+/jMVBAPd18f3FLn8EdpSudD4bffCbGBCX1pq30LdUb xBpzOPclfpQln19/XQaswOtTPZCPPTI= Date: Sun, 27 Mar 2022 23:38:43 +0200 From: Borislav Petkov To: Ammar Faizi Cc: Thomas Gleixner , Alviro Iskandar Setiawan , Alviro Iskandar Setiawan , Dave Hansen , Greg Kroah-Hartman , "H. Peter Anvin" , Ingo Molnar , Tony Luck , Yazen Ghannam , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, gwml@vger.gnuweeb.org, x86@kernel.org, David Laight , Jiri Hladky Subject: Re: [PATCH v5 1/2] x86/delay: Fix the wrong asm constraint in `delay_loop()` Message-ID: References: <20220310015306.445359-1-ammarfaizi2@gnuweeb.org> <20220310015306.445359-2-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220310015306.445359-2-ammarfaizi2@gnuweeb.org> List-Id: On Thu, Mar 10, 2022 at 08:53:05AM +0700, Ammar Faizi wrote: > The asm constraint does not reflect that the asm statement can modify > the value of @loops. But the asm statement in delay_loop() does modify > the @loops. > > Specifiying the wrong constraint may lead to undefined behavior, it may > clobber random stuff (e.g. local variable, important temporary value in > regs, etc.). This is especially dangerous when the compiler decides to inline the function and since it doesn't know that the value gets modified, it might decide to use it from a register directly without reloading it. Add that to the commit message pls. > Fix this by changing the constraint from "a" (as an input) to "+a" (as > an input and output). > > Cc: David Laight > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: Dave Hansen > Cc: "H. Peter Anvin" > Cc: Jiri Hladky All those Ccs in the commit message are not really needed - get_maintainers.pl gives the correct list already. > Cc: stable@vger.kernel.org # v2.6.27+ I don't see the need for the stable Cc. Or do you have a case where a corruption really does happen? > Fixes: e01b70ef3eb ("x86: fix bug in arch/i386/lib/delay.c file, delay_loop function") Commit sha1 (e01b70ef3eb) needs to be at least 12 chars long: e01b70ef3eb3 ("x86: fix bug in arch/i386/lib/delay.c file, delay_loop function") This is best fixed by doing: [core] abbrev = 12 in your .git/config > Signed-off-by: Ammar Faizi > --- > arch/x86/lib/delay.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c > index 65d15df6212d..0e65d00e2339 100644 > --- a/arch/x86/lib/delay.c > +++ b/arch/x86/lib/delay.c > @@ -54,8 +54,8 @@ static void delay_loop(u64 __loops) > " jnz 2b \n" > "3: dec %0 \n" > > - : /* we don't need output */ > - :"a" (loops) > + : "+a" (loops) > + : > ); Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette