Skip to content

Commit b885858

Browse files
committed
powerpc/lib: Fix off-by-one in alternate feature patching
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: d20fe50 ("KVM: PPC: Book3S HV: Branch inside feature section") Fixes: 9b1a735 ("powerpc: Add logic to patch alternative feature sections") Cc: [email protected] # v2.6.27+ Signed-off-by: Michael Ellerman <[email protected]>
1 parent 60cc43f commit b885858

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/powerpc/lib/feature-fixups.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static int patch_alt_instruction(unsigned int *src, unsigned int *dest,
5555
unsigned int *target = (unsigned int *)branch_target(src);
5656

5757
/* Branch within the section doesn't need translating */
58-
if (target < alt_start || target >= alt_end) {
58+
if (target < alt_start || target > alt_end) {
5959
instr = translate_branch(dest, src);
6060
if (!instr)
6161
return 1;

0 commit comments

Comments
 (0)