public inbox for [email protected]
 help / color / mirror / Atom feed
* Patch "x86/delay: Fix the wrong asm constraint in delay_loop()" has been added to the 5.15-stable tree
@ 2022-06-06 12:21 Sasha Levin
  0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2022-06-06 12:21 UTC (permalink / raw)
  To: stable-commits, ammarfaizi2
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	gwml, H. Peter Anvin

This is a note to let you know that I've just added the patch titled

    x86/delay: Fix the wrong asm constraint in delay_loop()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-delay-fix-the-wrong-asm-constraint-in-delay_loop.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.



commit 699e8de9fdc19f54507baaa5de322f95ea98d8b7
Author: Ammar Faizi <[email protected]>
Date:   Tue Mar 29 17:47:04 2022 +0700

    x86/delay: Fix the wrong asm constraint in delay_loop()
    
    [ Upstream commit b86eb74098a92afd789da02699b4b0dd3f73b889 ]
    
    The asm constraint does not reflect the fact that the asm statement can
    modify the value of the local variable loops. Which it does.
    
    Specifying 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.
    
    Change the constraint to "+a" to denote that the first argument is an
    input and an output argument.
    
      [ bp: Fix typo, massage commit message. ]
    
    Fixes: e01b70ef3eb3 ("x86: fix bug in arch/i386/lib/delay.c file, delay_loop function")
    Signed-off-by: Ammar Faizi <[email protected]>
    Signed-off-by: Borislav Petkov <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

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)
+		:
 	);
 }
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-06 12:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-06 12:21 Patch "x86/delay: Fix the wrong asm constraint in delay_loop()" has been added to the 5.15-stable tree Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox