Skip to content

Commit 591d210

Browse files
committed
parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines
If a 32-bit kernel was compiled for PA2.0 CPUs, it won't be able to run on machines with PA1.x CPUs. Add a check and bail out early if a PA1.x machine is detected. Signed-off-by: Helge Deller <[email protected]>
1 parent d46c742 commit 591d210

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

arch/parisc/kernel/head.S

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <linux/init.h>
2323
#include <linux/pgtable.h>
2424

25-
.level PA_ASM_LEVEL
25+
.level 1.1
2626

2727
__INITDATA
2828
ENTRY(boot_args)
@@ -70,6 +70,47 @@ $bss_loop:
7070
stw,ma %arg2,4(%r1)
7171
stw,ma %arg3,4(%r1)
7272

73+
#if !defined(CONFIG_64BIT) && defined(CONFIG_PA20)
74+
/* This 32-bit kernel was compiled for PA2.0 CPUs. Check current CPU
75+
* and halt kernel if we detect a PA1.x CPU. */
76+
ldi 32,%r10
77+
mtctl %r10,%cr11
78+
.level 2.0
79+
mfctl,w %cr11,%r10
80+
.level 1.1
81+
comib,<>,n 0,%r10,$cpu_ok
82+
83+
load32 PA(msg1),%arg0
84+
ldi msg1_end-msg1,%arg1
85+
$iodc_panic:
86+
copy %arg0, %r10
87+
copy %arg1, %r11
88+
load32 PA(init_stack),%sp
89+
#define MEM_CONS 0x3A0
90+
ldw MEM_CONS+32(%r0),%arg0 // HPA
91+
ldi ENTRY_IO_COUT,%arg1
92+
ldw MEM_CONS+36(%r0),%arg2 // SPA
93+
ldw MEM_CONS+8(%r0),%arg3 // layers
94+
load32 PA(__bss_start),%r1
95+
stw %r1,-52(%sp) // arg4
96+
stw %r0,-56(%sp) // arg5
97+
stw %r10,-60(%sp) // arg6 = ptr to text
98+
stw %r11,-64(%sp) // arg7 = len
99+
stw %r0,-68(%sp) // arg8
100+
load32 PA(.iodc_panic_ret), %rp
101+
ldw MEM_CONS+40(%r0),%r1 // ENTRY_IODC
102+
bv,n (%r1)
103+
.iodc_panic_ret:
104+
b . /* wait endless with ... */
105+
or %r10,%r10,%r10 /* qemu idle sleep */
106+
msg1: .ascii "Can't boot kernel which was built for PA8x00 CPUs on this machine.\r\n"
107+
msg1_end:
108+
109+
$cpu_ok:
110+
#endif
111+
112+
.level PA_ASM_LEVEL
113+
73114
/* Initialize startup VM. Just map first 16/32 MB of memory */
74115
load32 PA(swapper_pg_dir),%r4
75116
mtctl %r4,%cr24 /* Initialize kernel root pointer */

0 commit comments

Comments
 (0)