Skip to content

Commit 15eb240

Browse files
author
Delphix Engineering
committed
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
2 parents 625b60a + 764baba commit 15eb240

12 files changed

+203
-43
lines changed

src/addrxlat/x86_64.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,10 @@ linux_ktext_extents(struct os_init_data *ctl,
541541

542542
linearoff = ctl->sys->meth[ADDRXLAT_SYS_METH_KTEXT].param.linear.off;
543543
*high = *low;
544-
status = highest_linear(&step, high, LINUX_KTEXT_END_NOKASLR,
545-
linearoff);
546-
if (status == ADDRXLAT_OK && *high == LINUX_KTEXT_END_NOKASLR) {
544+
if (*high <= LINUX_KTEXT_END_NOKASLR)
545+
status = highest_linear(&step, high, LINUX_KTEXT_END_NOKASLR,
546+
linearoff);
547+
if (status == ADDRXLAT_OK && *high >= LINUX_KTEXT_END_NOKASLR) {
547548
++*high;
548549
status = highest_linear(&step, high, LINUX_KTEXT_END,
549550
linearoff);

src/kdumpfile/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ read_blob_attr(kdump_ctx_t *ctx, unsigned fidx, off_t off, size_t size,
13451345
struct fcache_chunk fch;
13461346
kdump_status ret;
13471347

1348-
ret = fcache_get_chunk(ctx->shared->fcache, &fch, size, fidx, off);
1348+
ret = flatmap_get_chunk(ctx->shared->flatmap, &fch, size, fidx, off);
13491349
if (ret != KDUMP_OK)
13501350
return set_error(ctx, ret,
13511351
"Cannot read %s (%zu bytes at %llu in %s)",

tests/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ test_scripts = \
196196
diskdump-empty-s390x \
197197
diskdump-empty-x86_64 \
198198
diskdump-basic-raw \
199+
diskdump-basic-vmcoreinfo \
199200
diskdump-flat-raw \
201+
diskdump-flat-vmcoreinfo \
200202
diskdump-multiread \
201203
diskdump-excluded \
202204
diskdump-split \
@@ -295,6 +297,7 @@ test_scripts = \
295297
xlat-linux-x86_64-ktext-40M \
296298
xlat-linux-x86_64-ktext-512M \
297299
xlat-linux-x86_64-ktext-520M \
300+
xlat-linux-x86_64-ktext-54M-kaslr \
298301
xlat-linux-x86_64-old \
299302
xlat-linux-x86_64-old-nover \
300303
xlat-linux-x86_64-2.6.11 \
@@ -392,6 +395,7 @@ dist_check_DATA = \
392395
diskdump-split.expect.3 \
393396
sys-xlat-x86_64-linux.expect \
394397
sys-xlat-x86_64-linux-xen.expect \
398+
vmcoreinfo.data \
395399
xlatmap.expect \
396400
xlat-os-aarch64-none.expect \
397401
xlat-os-ia32-none.expect \
@@ -476,6 +480,9 @@ dist_check_DATA = \
476480
xlat-linux-x86_64-ktext-520M.data \
477481
xlat-linux-x86_64-ktext-520M.expect \
478482
xlat-linux-x86_64-ktext-520M.sym \
483+
xlat-linux-x86_64-ktext-54M-kaslr.data \
484+
xlat-linux-x86_64-ktext-54M-kaslr.expect \
485+
xlat-linux-x86_64-ktext-54M-kaslr.sym \
479486
xlat-linux-x86_64-old.expect \
480487
xlat-linux-x86_64-old-nover.data \
481488
xlat-linux-x86_64-old-nover.expect \

tests/diskdump-basic

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ echo "@0 $pageflags" > "$datafile"
1414
cat "$expectfile" >> "$datafile"
1515

1616
./mkdiskdump "$dumpfile" <<EOF
17-
$extraparam
1817
version = 6
1918
arch_name = x86_64
2019
block_size = 4096
@@ -32,6 +31,7 @@ uts.domainname = (none)
3231
nr_cpus = 1
3332

3433
DATA = $datafile
34+
$extraparam
3535
EOF
3636
rc=$?
3737
if [ $rc -ne 0 ]; then
@@ -43,6 +43,7 @@ echo "Created DISKDUMP dump: $dumpfile"
4343
./checkattr "$dumpfile" <<EOF
4444
file.pagemap = bitmap: 1
4545
memory.pagemap = bitmap: 1
46+
$extracheckattr
4647
EOF
4748
rc=$?
4849
if [ $rc -ne 0 ]; then

tests/diskdump-basic-vmcoreinfo

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#! /bin/sh
2+
3+
#
4+
# Create a diskdump file with VMCOREINFO data. The corresponding header field
5+
# was added in v3 and superseded by ELF notes in v4, so the version is forced
6+
# to v3 here.
7+
#
8+
9+
pageflags=raw
10+
extraparam="
11+
version = 3
12+
VMCOREINFO = vmcoreinfo.data
13+
"
14+
extracheckattr="
15+
linux.vmcoreinfo.lines.OSRELEASE = string:6.4.3-1-default
16+
linux.vmcoreinfo.lines.PAGESIZE = string:4096
17+
linux.vmcoreinfo.lines.CRASHTIME = string:1689103980
18+
"
19+
. "$srcdir"/diskdump-basic
20+
exit 0

tests/diskdump-flat-vmcoreinfo

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#! /bin/sh
2+
3+
#
4+
# Create a flattened diskdump file with VMCOREINFO data.
5+
# See also diskdump-basic-vmcoreinfo.
6+
#
7+
8+
pageflags=raw
9+
extraparam="
10+
flattened = yes
11+
version = 3
12+
VMCOREINFO = vmcoreinfo.data
13+
"
14+
extracheckattr="
15+
linux.vmcoreinfo.lines.OSRELEASE = string:6.4.3-1-default
16+
linux.vmcoreinfo.lines.PAGESIZE = string:4096
17+
linux.vmcoreinfo.lines.CRASHTIME = string:1689103980
18+
"
19+
. "$srcdir"/diskdump-basic
20+
exit 0

tests/mkdiskdump.c

Lines changed: 79 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ enum compress_method {
8585
COMPRESS_ZSTD,
8686
};
8787

88-
struct data_block {
89-
off_t filepos;
90-
struct blob *blob;
91-
};
92-
9388
static bool flattened;
9489
static unsigned long long flattened_type = MDF_TYPE_FLAT_HEADER;
9590
static unsigned long long flattened_version = MDF_VERSION_FLAT_HEADER;
@@ -123,9 +118,9 @@ static unsigned long long split;
123118
static unsigned long long start_pfn;
124119
static unsigned long long end_pfn;
125120

126-
static struct data_block vmcoreinfo;
127-
static struct data_block notes;
128-
static struct data_block eraseinfo;
121+
static struct blob *vmcoreinfo;
122+
static struct blob *notes;
123+
static struct blob *eraseinfo;
129124

130125
static char *vmcoreinfo_file;
131126
static char *note_file;
@@ -251,6 +246,7 @@ writeheader_32(FILE *f)
251246
struct timeval tv;
252247
struct disk_dump_header_32 hdr;
253248
struct kdump_sub_header_32 subhdr;
249+
off_t pos;
254250

255251
if (gettimeofday(&tv, NULL) != 0) {
256252
perror("gettimeofday");
@@ -290,23 +286,45 @@ writeheader_32(FILE *f)
290286
if (write_chunk(f, 0, &hdr, sizeof hdr, "header"))
291287
return TEST_ERR;
292288

289+
pos = DISKDUMP_HEADER_BLOCKS * block_size + sizeof(subhdr);
293290
subhdr.phys_base = htodump32(be, phys_base);
294291
subhdr.dump_level = htodump32(be, dump_level);
295292
subhdr.split = htodump32(be, split);
296293
subhdr.start_pfn = htodump32(be, start_pfn);
297294
subhdr.end_pfn = htodump32(be, end_pfn);
298-
subhdr.offset_vmcoreinfo = htodump64(be, vmcoreinfo.filepos);
299-
subhdr.size_vmcoreinfo = htodump32(be, (vmcoreinfo.blob
300-
? vmcoreinfo.blob->length
301-
: 0));
302-
subhdr.offset_note = htodump64(be, notes.filepos);
303-
subhdr.size_note = htodump32(be, (notes.blob
304-
? notes.blob->length
305-
: 0));
306-
subhdr.offset_eraseinfo = htodump64(be, eraseinfo.filepos);
307-
subhdr.size_eraseinfo = htodump32(be, (eraseinfo.blob
308-
? eraseinfo.blob->length
309-
: 0));
295+
if (vmcoreinfo) {
296+
subhdr.offset_vmcoreinfo = htodump64(be, pos);
297+
subhdr.size_vmcoreinfo = htodump32(be, vmcoreinfo->length);
298+
if (write_chunk(f, pos, vmcoreinfo->data, vmcoreinfo->length,
299+
"VMCOREINFO"))
300+
return TEST_ERR;
301+
pos += vmcoreinfo->length;
302+
} else {
303+
subhdr.offset_vmcoreinfo = htodump64(be, 0);
304+
subhdr.size_vmcoreinfo = htodump32(be, 0);
305+
}
306+
if (notes) {
307+
subhdr.offset_note = htodump64(be, pos);
308+
subhdr.size_note = htodump32(be, notes->length);
309+
if (write_chunk(f, pos, notes->data, notes->length,
310+
"ELF notes"))
311+
return TEST_ERR;
312+
pos += notes->length;
313+
} else {
314+
subhdr.offset_note = htodump64(be, 0);
315+
subhdr.size_note = htodump32(be, 0);
316+
}
317+
if (eraseinfo) {
318+
subhdr.offset_eraseinfo = htodump64(be, pos);
319+
subhdr.size_eraseinfo = htodump32(be, eraseinfo->length);
320+
if (write_chunk(f, pos, notes->data, notes->length,
321+
"eraseinfo"))
322+
return TEST_ERR;
323+
pos += eraseinfo->length;
324+
} else {
325+
subhdr.offset_eraseinfo = htodump64(be, 0);
326+
subhdr.size_eraseinfo = htodump32(be, 0);
327+
}
310328
subhdr.start_pfn_64 = htodump64(be, start_pfn);
311329
subhdr.end_pfn_64 = htodump64(be, end_pfn);
312330
subhdr.max_mapnr_64 = htodump64(be, max_mapnr);
@@ -324,6 +342,7 @@ writeheader_64(FILE *f)
324342
struct timeval tv;
325343
struct disk_dump_header_64 hdr;
326344
struct kdump_sub_header_64 subhdr;
345+
off_t pos;
327346

328347
if (gettimeofday(&tv, NULL) != 0) {
329348
perror("gettimeofday");
@@ -363,23 +382,45 @@ writeheader_64(FILE *f)
363382
if (write_chunk(f, 0, &hdr, sizeof hdr, "header"))
364383
return TEST_ERR;
365384

385+
pos = DISKDUMP_HEADER_BLOCKS * block_size + sizeof(subhdr);
366386
subhdr.phys_base = htodump64(be, phys_base);
367387
subhdr.dump_level = htodump32(be, dump_level);
368388
subhdr.split = htodump32(be, split);
369389
subhdr.start_pfn = htodump64(be, start_pfn);
370390
subhdr.end_pfn = htodump64(be, end_pfn);
371-
subhdr.offset_vmcoreinfo = htodump64(be, vmcoreinfo.filepos);
372-
subhdr.size_vmcoreinfo = htodump64(be, (vmcoreinfo.blob
373-
? vmcoreinfo.blob->length
374-
: 0));
375-
subhdr.offset_note = htodump64(be, notes.filepos);
376-
subhdr.size_note = htodump64(be, (notes.blob
377-
? notes.blob->length
378-
: 0));
379-
subhdr.offset_eraseinfo = htodump64(be, eraseinfo.filepos);
380-
subhdr.size_eraseinfo = htodump64(be, (eraseinfo.blob
381-
? eraseinfo.blob->length
382-
: 0));
391+
if (vmcoreinfo) {
392+
subhdr.offset_vmcoreinfo = htodump64(be, pos);
393+
subhdr.size_vmcoreinfo = htodump64(be, vmcoreinfo->length);
394+
if (write_chunk(f, pos, vmcoreinfo->data, vmcoreinfo->length,
395+
"VMCOREINFO"))
396+
return TEST_ERR;
397+
pos += vmcoreinfo->length;
398+
} else {
399+
subhdr.offset_vmcoreinfo = htodump64(be, 0);
400+
subhdr.size_vmcoreinfo = htodump64(be, 0);
401+
}
402+
if (notes) {
403+
subhdr.offset_note = htodump64(be, pos);
404+
subhdr.size_note = htodump64(be, notes->length);
405+
if (write_chunk(f, pos, notes->data, notes->length,
406+
"ELF notes"))
407+
return TEST_ERR;
408+
pos += notes->length;
409+
} else {
410+
subhdr.offset_note = htodump64(be, 0);
411+
subhdr.size_note = htodump64(be, 0);
412+
}
413+
if (eraseinfo) {
414+
subhdr.offset_eraseinfo = htodump64(be, pos);
415+
subhdr.size_eraseinfo = htodump64(be, eraseinfo->length);
416+
if (write_chunk(f, pos, notes->data, notes->length,
417+
"eraseinfo"))
418+
return TEST_ERR;
419+
pos += eraseinfo->length;
420+
} else {
421+
subhdr.offset_eraseinfo = htodump64(be, 0);
422+
subhdr.size_eraseinfo = htodump64(be, 0);
423+
}
383424
subhdr.start_pfn_64 = htodump64(be, start_pfn);
384425
subhdr.end_pfn_64 = htodump64(be, end_pfn);
385426
subhdr.max_mapnr_64 = htodump64(be, max_mapnr);
@@ -904,20 +945,20 @@ main(int argc, char **argv)
904945
return rc;
905946

906947
if (vmcoreinfo_file) {
907-
vmcoreinfo.blob = slurp(vmcoreinfo_file);
908-
if (vmcoreinfo.blob == NULL)
948+
vmcoreinfo = slurp(vmcoreinfo_file);
949+
if (vmcoreinfo == NULL)
909950
return TEST_ERR;
910951
}
911952

912953
if (note_file) {
913-
notes.blob = slurp(note_file);
914-
if (notes.blob == NULL)
954+
notes = slurp(note_file);
955+
if (notes == NULL)
915956
return TEST_ERR;
916957
}
917958

918959
if (eraseinfo_file) {
919-
eraseinfo.blob = slurp(eraseinfo_file);
920-
if (eraseinfo.blob == NULL)
960+
eraseinfo = slurp(eraseinfo_file);
961+
if (eraseinfo == NULL)
921962
return TEST_ERR;
922963
}
923964

tests/vmcoreinfo.data

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
OSRELEASE=6.4.3-1-default
2+
PAGESIZE=4096
3+
CRASHTIME=1689103980
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#! /bin/bash
2+
3+
#
4+
# Check Linux X86_64 translation with a 54M kASLR ktext mapping starting
5+
# above the fixed (non-kASLR) virtual address region.
6+
#
7+
8+
opts=(
9+
arch=x86_64
10+
ostype=linux
11+
phys_base=0x23c00000
12+
)
13+
14+
. "$srcdir"/xlat-os-common
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# kernel text
2+
@0x4c610ff8
3+
000000004c615067
4+
@0x4c615ff0
5+
000000004c616063
6+
@0x4c616000
7+
0000000000000000*313
8+
000000004ae001e1*27+200000
9+
0000000000000000*172
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@rootpgt: PGT
2+
target_as=MACHPHYSADDR
3+
root=KVADDR:0xffffffffa8a10000
4+
pte_mask=0x0
5+
pte_format=x86_64
6+
fields=12,9,9,9,9
7+
8+
@ktext: LINEAR
9+
target_as=KPHYSADDR
10+
off=0xa3c00000
11+
12+
@machphys_kphys: LINEAR
13+
target_as=KPHYSADDR
14+
off=0x0
15+
16+
@kphys_machphys: LINEAR
17+
target_as=MACHPHYSADDR
18+
off=0x0
19+
20+
KV -> HW:
21+
0-7fffffffffff: @rootpgt
22+
800000000000-ffff7fffffffffff: NONE
23+
ffff800000000000-ffffffffffffffff: @rootpgt
24+
25+
KV -> PHYS:
26+
0-7fffffffffff: @rootpgt
27+
800000000000-ffff7fffffffffff: NONE
28+
ffff800000000000-ffffffffa71fffff: @rootpgt
29+
ffffffffa7200000-ffffffffaa7fffff: @ktext
30+
ffffffffaa800000-ffffffffffffffff: @rootpgt
31+
32+
KPHYS -> DIRECT:
33+
34+
MACHPHYS -> KPHYS:
35+
0-fffffffffffff: @machphys_kphys
36+
10000000000000-ffffffffffffffff: NONE
37+
38+
KPHYS -> MACHPHYS:
39+
0-fffffffffffff: @kphys_machphys
40+
10000000000000-ffffffffffffffff: NONE
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@VALUE(init_top_pgt)
2+
ffffffffa8a10000
3+
@VALUE(_stext)
4+
ffffffffa7200000

0 commit comments

Comments
 (0)