Skip to contentSkip to conversation

FAILED: patch "[PATCH] x86/module: Fix the paravirt vs alternative order" failed to apply to 5.15-stable tree

PATCH [email protected] 2 participants 3 messages Mar 14, 2022 – Mar 17, 2022

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 5adf349439d29f92467e864f728dfc23180f3ef9 Mon Sep 17 00:00:00 2001
From: Peter Zijlstra <[email protected]>
Date: Thu, 3 Mar 2022 12:23:23 +0100
Subject: [PATCH] x86/module: Fix the paravirt vs alternative order

Ever since commit

4e6292114c74 ("x86/paravirt: Add new features for paravirt patching")

there is an ordering dependency between patching paravirt ops and patching alternatives, the module loader still violates this.

Fixes 4e6292114c74 ("x86/paravirt: Add new features for paravirt patching")
arch/x86/kernel/module.c +8 -5
index 95fa745e310a..96d7c27b7093 100644
@@ -273,6 +273,14 @@ int module_finalize(const Elf_Ehdr *hdr,
 			retpolines = s;
 	}
 
+	/*
+	 * See alternative_instructions() for the ordering rules between the
+	 * various patching types.
+	 */
+	if (para) {
+		void *pseg = (void *)para->sh_addr;
+		apply_paravirt(pseg, pseg + para->sh_size);
+	}
 	if (retpolines) {
 		void *rseg = (void *)retpolines->sh_addr;
 		apply_retpolines(rseg, rseg + retpolines->sh_size);
@@ -290,11 +298,6 @@ int module_finalize(const Elf_Ehdr *hdr,
 					    tseg, tseg + text->sh_size);
 	}
 
-	if (para) {
-		void *pseg = (void *)para->sh_addr;
-		apply_paravirt(pseg, pseg + para->sh_size);
-	}
-
 	/* make jump label nops */
 	jump_label_apply_nops(me);
 
Reviewed-by Miroslav Benes
#1 lore raw
Quoted 6 lines · On Mon, Mar 14, 2022 at 09:04:06AM +0100, [email protected] wrote:

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Quoted 7 lines

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 5adf349439d29f92467e864f728dfc23180f3ef9 Mon Sep 17 00:00:00 2001

I guess something like this:

From 8fb38dd5ae4b4f94e5944651965d4b2e8168d46a Mon Sep 17 00:00:00 2001
From: Peter Zijlstra <[email protected]>
Date: Thu, 3 Mar 2022 12:23:23 +0100
Subject: [PATCH] x86/module: Fix the paravirt vs alternative order

Commit 5adf349439d29f92467e864f728dfc23180f3ef9 upstream.

Ever since commit

4e6292114c74 ("x86/paravirt: Add new features for paravirt patching")

there is an ordering dependency between patching paravirt ops and patching alternatives, the module loader still violates this.

Fixes 4e6292114c74 ("x86/paravirt: Add new features for paravirt patching")
---
 arch/x86/kernel/module.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
arch/x86/kernel/module.c +8 -5
index 867a341a0c7e..32e546e41629 100644
@@ -270,6 +270,14 @@ int module_finalize(const Elf_Ehdr *hdr,
 			orc_ip = s;
 	}
 
+	/*
+	 * See alternative_instructions() for the ordering rules between the
+	 * various patching types.
+	 */
+	if (para) {
+		void *pseg = (void *)para->sh_addr;
+		apply_paravirt(pseg, pseg + para->sh_size);
+	}
 	if (alt) {
 		/* patch .altinstructions */
 		void *aseg = (void *)alt->sh_addr;
@@ -283,11 +291,6 @@ int module_finalize(const Elf_Ehdr *hdr,
 					    tseg, tseg + text->sh_size);
 	}
 
-	if (para) {
-		void *pseg = (void *)para->sh_addr;
-		apply_paravirt(pseg, pseg + para->sh_size);
-	}
-
 	/* make jump label nops */
 	jump_label_apply_nops(me);
 
Signature · 7 lines
2.29.2

-- 
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Ivo Totev, HRB 36809, AG Nürnberg
author maintainer
#2 lore raw
Quoted 9 lines · Borislav Petkov
Quoted 8 lines · On Mon, Mar 14, 2022 at 09:04:06AM +0100, [email protected] wrote:

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

Quoted 8 lines
Quoted 5 lines

greg k-h

------------------ original commit in Linus's tree ------------------

From 5adf349439d29f92467e864f728dfc23180f3ef9 Mon Sep 17 00:00:00 2001

I guess something like this:

Thanks for the backport, now queued up!

greg k-h