linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] powerpc/lib: Fix off-by-one in alternate feature patching
@ 2018-04-16 14:39 Michael Ellerman
  2018-04-16 14:39 ` [PATCH 2/5] powerpc/lib: Fix feature fixup test of external branch Michael Ellerman
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Michael Ellerman @ 2018-04-16 14:39 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus, aik

When we patch an alternate feature section, we have to adjust any
relative branches that branch out of the alternate section.

But currently we have a bug if we have a branch that points to past
the last instruction of the alternate section, eg:

  FTR_SECTION_ELSE
  1:     b       2f
         or      6,6,6
  2:
  ALT_FTR_SECTION_END(...)
         nop

This will result in a relative branch at 1 with a target that equals
the end of the alternate section.

That branch does not need adjusting when it's moved to the non-else
location. Currently we do adjust it, resulting in a branch that goes
off into the link-time location of the else section, which is junk.

The fix is to not patch branches that have a target == end of the
alternate section.

Fixes: d20fe50a7b3c ("KVM: PPC: Book3S HV: Branch inside feature section")
Fixes: 9b1a735de64c ("powerpc: Add logic to patch alternative feature sections")
Cc: stable@vger.kernel.org # v2.6.27+
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/lib/feature-fixups.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c
index 35f80ab7cbd8..288fe4f0db4e 100644
--- a/arch/powerpc/lib/feature-fixups.c
+++ b/arch/powerpc/lib/feature-fixups.c
@@ -55,7 +55,7 @@ static int patch_alt_instruction(unsigned int *src, unsigned int *dest,
 		unsigned int *target = (unsigned int *)branch_target(src);
 
 		/* Branch within the section doesn't need translating */
-		if (target < alt_start || target >= alt_end) {
+		if (target < alt_start || target > alt_end) {
 			instr = translate_branch(dest, src);
 			if (!instr)
 				return 1;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-16 13:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-16 14:39 [PATCH 1/5] powerpc/lib: Fix off-by-one in alternate feature patching Michael Ellerman
2018-04-16 14:39 ` [PATCH 2/5] powerpc/lib: Fix feature fixup test of external branch Michael Ellerman
2018-05-16 13:38   ` [2/5] " Michael Ellerman
2018-04-16 14:39 ` [PATCH 3/5] powerpc/lib: Fix the feature fixup tests to actually work Michael Ellerman
2018-04-16 14:39 ` [PATCH 4/5] powerpc/lib: Rename ftr_fixup_test7 to ftr_fixup_test_too_big Michael Ellerman
2018-04-16 14:39 ` [PATCH 5/5] powerpc/lib: Add alt patching test of branching past the last instruction Michael Ellerman
2018-04-17 10:13 ` [1/5] powerpc/lib: Fix off-by-one in alternate feature patching Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).