public inbox for [email protected]
 help / color / mirror / Atom feed
From: Sasha Levin <[email protected]>
To: [email protected], [email protected]
Cc: Thomas Gleixner <[email protected]>,
	Ingo Molnar <[email protected]>, Borislav Petkov <[email protected]>,
	Dave Hansen <[email protected]>,
	[email protected], [email protected],
	"H. Peter Anvin" <[email protected]>
Subject: Patch "x86/delay: Fix the wrong asm constraint in delay_loop()" has been added to the 5.15-stable tree
Date: Mon,  6 Jun 2022 08:21:45 -0400	[thread overview]
Message-ID: <[email protected]> (raw)

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

                 reply	other threads:[~2022-06-06 12:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox