Skip to content

Commit 6f79d33

Browse files
Michael Holzheutorvalds
authored andcommitted
s390/vmcore: use vmcore for zfcpdump
Modify the s390 copy_oldmem_page() and remap_oldmem_pfn_range() function for zfcpdump to read from the HSA memory if memory below HSA_SIZE bytes is requested. Otherwise real memory is used. Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com> Cc: Jan Willeke <willeke@de.ibm.com> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 11e376a commit 6f79d33

4 files changed

Lines changed: 110 additions & 22 deletions

File tree

‎arch/s390/Kconfig‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ config CRASH_DUMP
526526
bool "kernel crash dumps"
527527
depends on 64BIT && SMP
528528
select KEXEC
529+
select ZFCPDUMP
529530
help
530531
Generate crash dump after being started by kexec.
531532
Crash dump kernels are loaded in the main kernel with kexec-tools
@@ -536,7 +537,7 @@ config CRASH_DUMP
536537
config ZFCPDUMP
537538
def_bool n
538539
prompt "zfcpdump support"
539-
select SMP
540+
depends on SMP
540541
help
541542
Select this option if you want to build an zfcpdump enabled kernel.
542543
Refer to <file:Documentation/s390/zfcpdump.txt> for more details on this.

‎arch/s390/include/asm/sclp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ bool sclp_has_linemode(void);
5656
bool sclp_has_vt220(void);
5757
int sclp_pci_configure(u32 fid);
5858
int sclp_pci_deconfigure(u32 fid);
59+
int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode);
5960

6061
#endif /* _ASM_S390_SCLP_H */

‎arch/s390/kernel/crash_dump.c‎

Lines changed: 104 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <asm/os_info.h>
1717
#include <asm/elf.h>
1818
#include <asm/ipl.h>
19+
#include <asm/sclp.h>
1920

2021
#define PTR_ADD(x, y) (((char *) (x)) + ((unsigned long) (y)))
2122
#define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y)))
@@ -69,22 +70,41 @@ static ssize_t copy_page_real(void *buf, void *src, size_t csize)
6970
static void *elfcorehdr_newmem;
7071

7172
/*
72-
* Copy one page from "oldmem"
73+
* Copy one page from zfcpdump "oldmem"
74+
*
75+
* For pages below ZFCPDUMP_HSA_SIZE memory from the HSA is copied. Otherwise
76+
* real memory copy is used.
77+
*/
78+
static ssize_t copy_oldmem_page_zfcpdump(char *buf, size_t csize,
79+
unsigned long src, int userbuf)
80+
{
81+
int rc;
82+
83+
if (src < ZFCPDUMP_HSA_SIZE) {
84+
rc = memcpy_hsa(buf, src, csize, userbuf);
85+
} else {
86+
if (userbuf)
87+
rc = copy_to_user_real((void __force __user *) buf,
88+
(void *) src, csize);
89+
else
90+
rc = memcpy_real(buf, (void *) src, csize);
91+
}
92+
return rc ? rc : csize;
93+
}
94+
95+
/*
96+
* Copy one page from kdump "oldmem"
7397
*
7498
* For the kdump reserved memory this functions performs a swap operation:
7599
* - [OLDMEM_BASE - OLDMEM_BASE + OLDMEM_SIZE] is mapped to [0 - OLDMEM_SIZE].
76100
* - [0 - OLDMEM_SIZE] is mapped to [OLDMEM_BASE - OLDMEM_BASE + OLDMEM_SIZE]
77101
*/
78-
ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
79-
size_t csize, unsigned long offset, int userbuf)
102+
static ssize_t copy_oldmem_page_kdump(char *buf, size_t csize,
103+
unsigned long src, int userbuf)
104+
80105
{
81-
unsigned long src;
82106
int rc;
83107

84-
if (!csize)
85-
return 0;
86-
87-
src = (pfn << PAGE_SHIFT) + offset;
88108
if (src < OLDMEM_SIZE)
89109
src += OLDMEM_BASE;
90110
else if (src > OLDMEM_BASE &&
@@ -95,17 +115,35 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
95115
(void *) src, csize);
96116
else
97117
rc = copy_page_real(buf, (void *) src, csize);
98-
return (rc == 0) ? csize : rc;
118+
return (rc == 0) ? rc : csize;
99119
}
100120

101121
/*
102-
* Remap "oldmem"
122+
* Copy one page from "oldmem"
123+
*/
124+
ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize,
125+
unsigned long offset, int userbuf)
126+
{
127+
unsigned long src;
128+
129+
if (!csize)
130+
return 0;
131+
src = (pfn << PAGE_SHIFT) + offset;
132+
if (OLDMEM_BASE)
133+
return copy_oldmem_page_kdump(buf, csize, src, userbuf);
134+
else
135+
return copy_oldmem_page_zfcpdump(buf, csize, src, userbuf);
136+
}
137+
138+
/*
139+
* Remap "oldmem" for kdump
103140
*
104141
* For the kdump reserved memory this functions performs a swap operation:
105142
* [0 - OLDMEM_SIZE] is mapped to [OLDMEM_BASE - OLDMEM_BASE + OLDMEM_SIZE]
106143
*/
107-
int remap_oldmem_pfn_range(struct vm_area_struct *vma, unsigned long from,
108-
unsigned long pfn, unsigned long size, pgprot_t prot)
144+
static int remap_oldmem_pfn_range_kdump(struct vm_area_struct *vma,
145+
unsigned long from, unsigned long pfn,
146+
unsigned long size, pgprot_t prot)
109147
{
110148
unsigned long size_old;
111149
int rc;
@@ -124,6 +162,43 @@ int remap_oldmem_pfn_range(struct vm_area_struct *vma, unsigned long from,
124162
return remap_pfn_range(vma, from, pfn, size, prot);
125163
}
126164

165+
/*
166+
* Remap "oldmem" for zfcpdump
167+
*
168+
* We only map available memory above ZFCPDUMP_HSA_SIZE. Memory below
169+
* ZFCPDUMP_HSA_SIZE is read on demand using the copy_oldmem_page() function.
170+
*/
171+
static int remap_oldmem_pfn_range_zfcpdump(struct vm_area_struct *vma,
172+
unsigned long from,
173+
unsigned long pfn,
174+
unsigned long size, pgprot_t prot)
175+
{
176+
unsigned long size_hsa;
177+
178+
if (pfn < ZFCPDUMP_HSA_SIZE >> PAGE_SHIFT) {
179+
size_hsa = min(size, ZFCPDUMP_HSA_SIZE - (pfn << PAGE_SHIFT));
180+
if (size == size_hsa)
181+
return 0;
182+
size -= size_hsa;
183+
from += size_hsa;
184+
pfn += size_hsa >> PAGE_SHIFT;
185+
}
186+
return remap_pfn_range(vma, from, pfn, size, prot);
187+
}
188+
189+
/*
190+
* Remap "oldmem" for kdump or zfcpdump
191+
*/
192+
int remap_oldmem_pfn_range(struct vm_area_struct *vma, unsigned long from,
193+
unsigned long pfn, unsigned long size, pgprot_t prot)
194+
{
195+
if (OLDMEM_BASE)
196+
return remap_oldmem_pfn_range_kdump(vma, from, pfn, size, prot);
197+
else
198+
return remap_oldmem_pfn_range_zfcpdump(vma, from, pfn, size,
199+
prot);
200+
}
201+
127202
/*
128203
* Copy memory from old kernel
129204
*/
@@ -132,11 +207,21 @@ int copy_from_oldmem(void *dest, void *src, size_t count)
132207
unsigned long copied = 0;
133208
int rc;
134209

135-
if ((unsigned long) src < OLDMEM_SIZE) {
136-
copied = min(count, OLDMEM_SIZE - (unsigned long) src);
137-
rc = memcpy_real(dest, src + OLDMEM_BASE, copied);
138-
if (rc)
139-
return rc;
210+
if (OLDMEM_BASE) {
211+
if ((unsigned long) src < OLDMEM_SIZE) {
212+
copied = min(count, OLDMEM_SIZE - (unsigned long) src);
213+
rc = memcpy_real(dest, src + OLDMEM_BASE, copied);
214+
if (rc)
215+
return rc;
216+
}
217+
} else {
218+
if ((unsigned long) src < ZFCPDUMP_HSA_SIZE) {
219+
copied = min(count,
220+
ZFCPDUMP_HSA_SIZE - (unsigned long) src);
221+
rc = memcpy_hsa(dest, (unsigned long) src, copied, 0);
222+
if (rc)
223+
return rc;
224+
}
140225
}
141226
return memcpy_real(dest + copied, src + copied, count - copied);
142227
}
@@ -466,7 +551,8 @@ int elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)
466551
u32 alloc_size;
467552
u64 hdr_off;
468553

469-
if (!OLDMEM_BASE)
554+
/* If we are not in kdump or zfcpdump mode return */
555+
if (!OLDMEM_BASE && ipl_info.type != IPL_TYPE_FCP_DUMP)
470556
return 0;
471557
/* If elfcorehdr= has been passed via cmdline, we use that one */
472558
if (elfcorehdr_addr != ELFCORE_ADDR_MAX)

‎drivers/s390/char/zcore.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#define TRACE(x...) debug_sprintf_event(zcore_dbf, 1, x)
3232

33-
#define TO_USER 0
34-
#define TO_KERNEL 1
33+
#define TO_USER 1
34+
#define TO_KERNEL 0
3535
#define CHUNK_INFO_SIZE 34 /* 2 16-byte char, each followed by blank */
3636

3737
enum arch_id {
@@ -73,7 +73,7 @@ static struct ipl_parameter_block *ipl_block;
7373
* @count: Size of buffer, which should be copied
7474
* @mode: Either TO_KERNEL or TO_USER
7575
*/
76-
static int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode)
76+
int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode)
7777
{
7878
int offs, blk_num;
7979
static char buf[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));

0 commit comments

Comments
 (0)