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=-4.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from gnuweeb.org by gnuweeb.org with LMTP id GwxAD33xnWK6DScALGQddQ (envelope-from ) for ; Mon, 06 Jun 2022 12:22:21 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by gnuweeb.org (Postfix) with ESMTPS id 11FBD7E582 for ; Mon, 6 Jun 2022 12:22:21 +0000 (UTC) Authentication-Results: gnuweeb.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=V5EVQhpk; dkim-atps=neutral Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 90DBBB818AC; Mon, 6 Jun 2022 12:21:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D77EC385A9; Mon, 6 Jun 2022 12:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654518108; bh=3o0o6akQCW9h2GY7M+RJRWc2roks4MNeG1Kr2IZCBpc=; h=From:To:Cc:Subject:Date:From; b=V5EVQhpkCUhmVQ/6FBKtz4H9vboeR68QRXuAFSidj1t4QcCEKpKzU7OrKL8+TZzGW KS5sAF5v+kHynC1EJx7H33OcIfk4lxvtb9hDtVW8xgeP45i7jy6AuZC4uAK0t4/lEB JjEZwTj2kJj6qqGu86zH6gjRkqMvHsqZ7VQJiek0KmwUgw9/uLCb2fvQdmhFSR7PKW nJpKMueX+cChIwlhu35mpDdbfk7J5OWINYibxyPOZoK+6S1mpxAq4VpRL47kkROO2v bwN7Lq8+4pDIsRj9eONDPmlTsLxQNW2qAmZ9OrcK8YFiSA8a2M5+sAJcKykh09mzMU 5PC32Jujpa26w== From: Sasha Levin To: stable-commits@vger.kernel.org, ammarfaizi2@gnuweeb.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, gwml@vger.gnuweeb.org, "H. Peter Anvin" 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 Message-Id: <20220606122145.169120-1-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Patchwork-Hint: ignore X-stable: review Content-Transfer-Encoding: 8bit List-Id: 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 know about it. commit 699e8de9fdc19f54507baaa5de322f95ea98d8b7 Author: Ammar Faizi 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 Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20220329104705.65256-2-ammarfaizi2@gnuweeb.org Signed-off-by: Sasha Levin 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) + : ); }