Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Add missing VZ accessor microMIPS encodings

Toolchains may be used which support microMIPS but not VZ instructions
(i.e. binutis 2.22 & 2.23), so extend the explicitly encoded versions of
the guest COP0 register & guest TLB access macros to support microMIPS
encodings too, using the new macros.

This prevents non-microMIPS instructions being executed in microMIPS
mode during CPU probe on cores supporting VZ (e.g. M5150), which cause
reserved instruction exceptions early during boot.

Fixes: bad50d79255a ("MIPS: Fix VZ probe gas errors with binutils <2.24")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/13311/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

James Hogan and committed by
Ralf Baechle
1c48a177 0dfa1c12

+18 -9
+18 -9
arch/mips/include/asm/mipsregs.h
··· 1773 1773 ".set\tpush\n\t" \ 1774 1774 ".set\tnoat\n\t" \ 1775 1775 "# mfgc0\t$1, $%1, %2\n\t" \ 1776 - ".word\t(0x40610000 | %1 << 11 | %2)\n\t" \ 1776 + _ASM_INSN_IF_MIPS(0x40610000 | %1 << 11 | %2) \ 1777 + _ASM_INSN32_IF_MM(0x002004fc | %1 << 16 | %2 << 11) \ 1777 1778 "move\t%0, $1\n\t" \ 1778 1779 ".set\tpop" \ 1779 1780 : "=r" (__res) \ ··· 1788 1787 ".set\tpush\n\t" \ 1789 1788 ".set\tnoat\n\t" \ 1790 1789 "# dmfgc0\t$1, $%1, %2\n\t" \ 1791 - ".word\t(0x40610100 | %1 << 11 | %2)\n\t" \ 1790 + _ASM_INSN_IF_MIPS(0x40610100 | %1 << 11 | %2) \ 1791 + _ASM_INSN32_IF_MM(0x582004fc | %1 << 16 | %2 << 11) \ 1792 1792 "move\t%0, $1\n\t" \ 1793 1793 ".set\tpop" \ 1794 1794 : "=r" (__res) \ ··· 1804 1802 ".set\tnoat\n\t" \ 1805 1803 "move\t$1, %z0\n\t" \ 1806 1804 "# mtgc0\t$1, $%1, %2\n\t" \ 1807 - ".word\t(0x40610200 | %1 << 11 | %2)\n\t" \ 1805 + _ASM_INSN_IF_MIPS(0x40610200 | %1 << 11 | %2) \ 1806 + _ASM_INSN32_IF_MM(0x002006fc | %1 << 16 | %2 << 11) \ 1808 1807 ".set\tpop" \ 1809 1808 : : "Jr" ((unsigned int)(value)), \ 1810 1809 "i" (register), "i" (sel)); \ ··· 1818 1815 ".set\tnoat\n\t" \ 1819 1816 "move\t$1, %z0\n\t" \ 1820 1817 "# dmtgc0\t$1, $%1, %2\n\t" \ 1821 - ".word\t(0x40610300 | %1 << 11 | %2)\n\t" \ 1818 + _ASM_INSN_IF_MIPS(0x40610300 | %1 << 11 | %2) \ 1819 + _ASM_INSN32_IF_MM(0x582006fc | %1 << 16 | %2 << 11) \ 1822 1820 ".set\tpop" \ 1823 1821 : : "Jr" (value), \ 1824 1822 "i" (register), "i" (sel)); \ ··· 2590 2586 { 2591 2587 __asm__ __volatile__( 2592 2588 "# tlbgp\n\t" 2593 - ".word 0x42000010"); 2589 + _ASM_INSN_IF_MIPS(0x42000010) 2590 + _ASM_INSN32_IF_MM(0x0000017c)); 2594 2591 } 2595 2592 2596 2593 static inline void guest_tlb_read(void) 2597 2594 { 2598 2595 __asm__ __volatile__( 2599 2596 "# tlbgr\n\t" 2600 - ".word 0x42000009"); 2597 + _ASM_INSN_IF_MIPS(0x42000009) 2598 + _ASM_INSN32_IF_MM(0x0000117c)); 2601 2599 } 2602 2600 2603 2601 static inline void guest_tlb_write_indexed(void) 2604 2602 { 2605 2603 __asm__ __volatile__( 2606 2604 "# tlbgwi\n\t" 2607 - ".word 0x4200000a"); 2605 + _ASM_INSN_IF_MIPS(0x4200000a) 2606 + _ASM_INSN32_IF_MM(0x0000217c)); 2608 2607 } 2609 2608 2610 2609 static inline void guest_tlb_write_random(void) 2611 2610 { 2612 2611 __asm__ __volatile__( 2613 2612 "# tlbgwr\n\t" 2614 - ".word 0x4200000e"); 2613 + _ASM_INSN_IF_MIPS(0x4200000e) 2614 + _ASM_INSN32_IF_MM(0x0000317c)); 2615 2615 } 2616 2616 2617 2617 /* ··· 2625 2617 { 2626 2618 __asm__ __volatile__( 2627 2619 "# tlbginvf\n\t" 2628 - ".word 0x4200000c"); 2620 + _ASM_INSN_IF_MIPS(0x4200000c) 2621 + _ASM_INSN32_IF_MM(0x0000517c)); 2629 2622 } 2630 2623 2631 2624 #endif /* !TOOLCHAIN_SUPPORTS_VIRT */