# kexec : Kernel unaligned instruction access\[\#1\] in second kernel

- From: Guruswamy Basavaiah \<hidden\>
- Date: 2021-07-07 07:58:51 
- List: linux-mips
- Page: https://ratatoskr.run/linux-mips/2021/07/14528661
- Thread: https://ratatoskr.run/linux-mips/2021/07/14528661/t.md

```text
Hello MIPS Linux community,
We are trying to use Linux kernel vmcore feature to capture the kernel
crash information on Cavium octeon board. Particularly on octeon2
(68xx) board. Could you please help in finding a way to debug this.

Issue is, when the second kernel is getting booted, at the very
initial stage of kernel boot we are getting "Kernel unaligned
instruction access[#1]:" error and the kernel is crashing.

Second kernel code, which is getting executed before kernel crash.
====
FEXPORT(octeon_hotplug_entry)
       move   a0, zero
       move   a0, zero
       move   a2, zero
       move   a3, zero
7:
#endif /* CONFIG_HOTPLUG_CPU */
       mfc0   v0, CP0_STATUS
       /* Force 64-bit addressing enabled */
       ori    v0, v0, (ST0_UX | ST0_SX | ST0_KX)
       /* Clear NMI and SR as they are sometimes restored and 0 -> 1
        * transitions are not allowed
        */
       li     v1, ~(ST0_NMI | ST0_SR)
       and    v0, v1
       mtc0   v0, CP0_STATUS
       # Clear the TLB.
       mfc0   v0, $16, 1     # Config1
       dsrl   v0, v0, 25
       andi   v0, v0, 0x3f
       mfc0   v1, $16, 3     # Config3
       bgez   v1, 1f
       mfc0   v1, $16, 4     # Config4
       andi   v1, 0x7f
       dsll   v1, 6
       or     v0, v0, v1
1:                             # Number of TLBs in v0
       dmtc0  zero, $2, 0    # EntryLo0
       dmtc0  zero, $3, 0    # EntryLo1
       dmtc0  zero, $5, 0    # PageMask
       tlbwi                  # Make it a 'normal' sized page
       daddiu t0, t0, 8192
       b      10b
1:
       mtc0   v0, $0, 0      # Index
       tlbwi
       .set   noreorder
       bne    v0, zero, 10b
        addiu v0, v0, -1
       .set   reorder
       mtc0   zero, $0, 0    # Index
       dmtc0  zero, $10, 0   # EntryHi
      dla    v0, continue_in_mapped_space
       jr     v0

continue_in_mapped_space:
        mfc0    v1, CP0_PRID_REG
...
=====
Here is the objdump of continue_in_mapped_space
ffffffff0be3f7b4 <continue_in_mapped_space>:
ffffffff0be3f7b4:      40037800       mfc0   v1,$15
ffffffff0be3f7b8:      3063ff00       andi   v1,v1,0xff00
ffffffff0be3f7bc:      34029500       li     v0,0x9500
ffffffff0be3f7c0:      00621823       subu   v1,v1,v0
ffffffff0be3f7c4:      240e0002       li     t2,2
ffffffff0be3f7c8:      04600002       bltz   v1,ffffffff0be3f7d4
<continue_in_mapped_space+0x20>
ffffffff0be3f7cc:      00000000       nop
ffffffff0be3f7d0:      25ce0001       addiu  t2,t2,1
ffffffff0be3f7d4:      40225807       dmfc0  v0,$11,7

Kernel unaligned instruction access[#1]: issue is happening at start
of continue_in_mapped_space function.

GCC used for compilation.
./mips64-linux-gnu-gcc --version
mips64-linux-gnu-gcc  4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Kernel is compiled with option -mabi=64 .

Second Kernel crash logs are attached.
-- 

Guruswamy Basavaiah
```

## Attachments

- [crash.txt](https://ratatoskr.run/linux-mips/2021/07/14528661/attachment/0) (text/plain, 9886 bytes)
