Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / arch / s390 / kernel / head_kdump.S
blobe1ac3893e972883e2c17b2787fad0a8857efc8d5
1 /*
2  * S390 kdump lowlevel functions (new kernel)
3  *
4  * Copyright IBM Corp. 2011
5  * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
6  */
8 #define DATAMOVER_ADDR  0x4000
9 #define COPY_PAGE_ADDR  0x6000
11 #ifdef CONFIG_CRASH_DUMP
14 # kdump entry (new kernel - not yet relocated)
16 # Note: This code has to be position independent
19 .align 2
20 .Lep_startup_kdump:
21         lhi     %r1,2                           # mode 2 = esame (dump)
22         sigp    %r1,%r0,0x12                    # Switch to esame mode
23         sam64                                   # Switch to 64 bit addressing
24         basr    %r13,0
25 .Lbase:
26         larl    %r2,.Lbase_addr                 # Check, if we have been
27         lg      %r2,0(%r2)                      # already relocated:
28         clgr    %r2,%r13                        #
29         jne     .Lrelocate                      # No : Start data mover
30         lghi    %r2,0                           # Yes: Start kdump kernel
31         brasl   %r14,startup_kdump_relocated
33 .Lrelocate:
34         larl    %r4,startup
35         lg      %r2,0x418(%r4)                  # Get kdump base
36         lg      %r3,0x420(%r4)                  # Get kdump size
38         larl    %r10,.Lcopy_start               # Source of data mover
39         lghi    %r8,DATAMOVER_ADDR              # Target of data mover
40         mvc     0(256,%r8),0(%r10)              # Copy data mover code
42         agr     %r8,%r2                         # Copy data mover to
43         mvc     0(256,%r8),0(%r10)              # reserved mem
45         lghi    %r14,DATAMOVER_ADDR             # Jump to copied data mover
46         basr    %r14,%r14
47 .Lbase_addr:
48         .quad   .Lbase
51 # kdump data mover code (runs at address DATAMOVER_ADDR)
53 # r2: kdump base address
54 # r3: kdump size
56 .Lcopy_start:
57         basr    %r13,0                          # Base
59         lgr     %r11,%r2                        # Save kdump base address
60         lgr     %r12,%r2
61         agr     %r12,%r3                        # Compute kdump end address
63         lghi    %r5,0
64         lghi    %r10,COPY_PAGE_ADDR             # Load copy page address
66         mvc     0(256,%r10),0(%r5)              # Copy old kernel to tmp
67         mvc     0(256,%r5),0(%r11)              # Copy new kernel to old
68         mvc     0(256,%r11),0(%r10)             # Copy tmp to new
69         aghi    %r11,256
70         aghi    %r5,256
71         clgr    %r11,%r12
72         jl      1b
74         lg      %r14,.Lstartup_kdump-0b(%r13)
75         basr    %r14,%r14                       # Start relocated kernel
76 .Lstartup_kdump:
77         .long   0x00000000,0x00000000 + startup_kdump_relocated
78 .Lcopy_end:
81 # Startup of kdump (relocated new kernel)
83 .align 2
84 startup_kdump_relocated:
85         basr    %r13,0
87         mvc     0(8,%r0),.Lrestart_psw-0b(%r13) # Setup restart PSW
88         mvc     464(16,%r0),.Lpgm_psw-0b(%r13)  # Setup pgm check PSW
89         lhi     %r1,1                           # Start new kernel
90         diag    %r1,%r1,0x308                   # with diag 308
92 .Lno_diag308:                                   # No diag 308
93         sam31                                   # Switch to 31 bit addr mode
94         sr      %r1,%r1                         # Erase register r1
95         sr      %r2,%r2                         # Erase register r2
96         sigp    %r1,%r2,0x12                    # Switch to 31 bit arch mode
97         lpsw    0                               # Start new kernel...
98 .align  8
99 .Lrestart_psw:
100         .long   0x00080000,0x80000000 + startup
101 .Lpgm_psw:
102         .quad   0x0000000180000000,0x0000000000000000 + .Lno_diag308
103 #else
104 .align 2
105 .Lep_startup_kdump:
106 #ifdef CONFIG_64BIT
107         larl    %r13,startup_kdump_crash
108         lpswe   0(%r13)
109 .align 8
110 startup_kdump_crash:
111         .quad   0x0002000080000000,0x0000000000000000 + startup_kdump_crash
112 #else
113         basr    %r13,0
114 0:      lpsw    startup_kdump_crash-0b(%r13)
115 .align 8
116 startup_kdump_crash:
117         .long   0x000a0000,0x00000000 + startup_kdump_crash
118 #endif /* CONFIG_64BIT */
119 #endif /* CONFIG_CRASH_DUMP */