Commit 74a2810b authored by Jinyang He's avatar Jinyang He Committed by Thomas Bogendoerfer

MIPS: KASLR: Correct valid bits in apply_r_mips_26_rel()

Apply_r_mips_26_rel() relocates instructions like j, jal and etc. These
instructions consist of 6bits function field and 26bits address field.
The value of target_addr as follows,
=================================================================
|     high 4bits           |            low 28bits              |
=================================================================
|the high 4bits of this PC | the low 26bits of instructions << 2|
=================================================================
Thus, loc_orig and log_new both need high 4bits rather than high 6bits.
Signed-off-by: default avatarJinyang He <hejinyang@loongson.cn>
Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
parent 91c7a7e0
...@@ -95,7 +95,7 @@ static int __init apply_r_mips_26_rel(u32 *loc_orig, u32 *loc_new, long offset) ...@@ -95,7 +95,7 @@ static int __init apply_r_mips_26_rel(u32 *loc_orig, u32 *loc_new, long offset)
/* Original target address */ /* Original target address */
target_addr <<= 2; target_addr <<= 2;
target_addr += (unsigned long)loc_orig & ~0x03ffffff; target_addr += (unsigned long)loc_orig & 0xf0000000;
/* Get the new target address */ /* Get the new target address */
target_addr += offset; target_addr += offset;
...@@ -105,7 +105,7 @@ static int __init apply_r_mips_26_rel(u32 *loc_orig, u32 *loc_new, long offset) ...@@ -105,7 +105,7 @@ static int __init apply_r_mips_26_rel(u32 *loc_orig, u32 *loc_new, long offset)
return -ENOEXEC; return -ENOEXEC;
} }
target_addr -= (unsigned long)loc_new & ~0x03ffffff; target_addr -= (unsigned long)loc_new & 0xf0000000;
target_addr >>= 2; target_addr >>= 2;
*loc_new = (*loc_new & ~0x03ffffff) | (target_addr & 0x03ffffff); *loc_new = (*loc_new & ~0x03ffffff) | (target_addr & 0x03ffffff);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment