MIPS: tlbex: Avoid unnecessary _PAGE_PRESENT shifts

Commit c5b367835c ("MIPS: Add support for XPA.") added generation of a
shift by _PAGE_PRESENT_SHIFT in build_pte_present() and
build_pte_writable(), however except for the XPA case this is always
zero making it unnecessary.

Make the shift conditional upon _PAGE_PRESENT_SHIFT being non-zero to
save an instruction in those cases.

Fixes: c5b367835c ("MIPS: Add support for XPA.")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Steven J. Hill <Steven.Hill@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9889/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
James Hogan 2015-04-27 15:07:18 +01:00 коммит произвёл Ralf Baechle
Родитель a3ae565a13
Коммит 8fe4908b83
1 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -1608,22 +1608,29 @@ build_pte_present(u32 **p, struct uasm_reloc **r,
int pte, int ptr, int scratch, enum label_id lid) int pte, int ptr, int scratch, enum label_id lid)
{ {
int t = scratch >= 0 ? scratch : pte; int t = scratch >= 0 ? scratch : pte;
int cur = pte;
if (cpu_has_rixi) { if (cpu_has_rixi) {
if (use_bbit_insns()) { if (use_bbit_insns()) {
uasm_il_bbit0(p, r, pte, ilog2(_PAGE_PRESENT), lid); uasm_il_bbit0(p, r, pte, ilog2(_PAGE_PRESENT), lid);
uasm_i_nop(p); uasm_i_nop(p);
} else { } else {
uasm_i_srl(p, t, pte, _PAGE_PRESENT_SHIFT); if (_PAGE_PRESENT_SHIFT) {
uasm_i_andi(p, t, t, 1); uasm_i_srl(p, t, cur, _PAGE_PRESENT_SHIFT);
cur = t;
}
uasm_i_andi(p, t, cur, 1);
uasm_il_beqz(p, r, t, lid); uasm_il_beqz(p, r, t, lid);
if (pte == t) if (pte == t)
/* You lose the SMP race :-(*/ /* You lose the SMP race :-(*/
iPTE_LW(p, pte, ptr); iPTE_LW(p, pte, ptr);
} }
} else { } else {
uasm_i_srl(p, t, pte, _PAGE_PRESENT_SHIFT); if (_PAGE_PRESENT_SHIFT) {
uasm_i_andi(p, t, t, uasm_i_srl(p, t, cur, _PAGE_PRESENT_SHIFT);
cur = t;
}
uasm_i_andi(p, t, cur,
(_PAGE_PRESENT | _PAGE_READ) >> _PAGE_PRESENT_SHIFT); (_PAGE_PRESENT | _PAGE_READ) >> _PAGE_PRESENT_SHIFT);
uasm_i_xori(p, t, t, uasm_i_xori(p, t, t,
(_PAGE_PRESENT | _PAGE_READ) >> _PAGE_PRESENT_SHIFT); (_PAGE_PRESENT | _PAGE_READ) >> _PAGE_PRESENT_SHIFT);
@ -1654,9 +1661,13 @@ build_pte_writable(u32 **p, struct uasm_reloc **r,
enum label_id lid) enum label_id lid)
{ {
int t = scratch >= 0 ? scratch : pte; int t = scratch >= 0 ? scratch : pte;
int cur = pte;
uasm_i_srl(p, t, pte, _PAGE_PRESENT_SHIFT); if (_PAGE_PRESENT_SHIFT) {
uasm_i_andi(p, t, t, uasm_i_srl(p, t, cur, _PAGE_PRESENT_SHIFT);
cur = t;
}
uasm_i_andi(p, t, cur,
(_PAGE_PRESENT | _PAGE_WRITE) >> _PAGE_PRESENT_SHIFT); (_PAGE_PRESENT | _PAGE_WRITE) >> _PAGE_PRESENT_SHIFT);
uasm_i_xori(p, t, t, uasm_i_xori(p, t, t,
(_PAGE_PRESENT | _PAGE_WRITE) >> _PAGE_PRESENT_SHIFT); (_PAGE_PRESENT | _PAGE_WRITE) >> _PAGE_PRESENT_SHIFT);