File: kvmdump.h

package info (click to toggle)
crash 7.0.8-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 36,348 kB
  • ctags: 13,100
  • sloc: ansic: 135,839; makefile: 495
file content (109 lines) | stat: -rw-r--r-- 2,542 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* 
 * kvmdump.h
 *
 * Copyright (C) 2009, 2010 David Anderson
 * Copyright (C) 2009, 2010 Red Hat, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

struct mapinfo_trailer {
	uint64_t map_start_offset;
	uint64_t phys_base;
	uint32_t cpu_version_id;
	uint32_t ram_version_id;
	uint64_t checksum;
	uint64_t magic;
};

struct register_set {
	uint32_t cs;
	uint32_t ss;
	uint32_t ds;
	uint32_t es;
	uint32_t fs;
	uint32_t gs;
	uint64_t ip;
	uint64_t flags;
	uint64_t regs[16];
};

#define REGS_MAGIC    (0xfeedbeefdeadbabeULL)
#define MAPFILE_MAGIC (0xfeedbabedeadbeefULL)
#define CHKSUM_SIZE   (4096)

#define KVMDUMP_CACHED_PAGES 32

struct kvmdump_data {
	ulong flags;
	FILE *ofp;
	FILE *vmp;
	int mapfd;
	int vmfd;
	struct mapinfo_trailer mapinfo;
        /* page cache */
        struct kvm_page_cache_hdr {
                uint64_t paddr;
               	char *bufptr;
        } page_cache[KVMDUMP_CACHED_PAGES];
	union {
		char *curbufptr;
		unsigned char compressed;
	} un;
        int evict_index;    
	ulong accesses;
	ulong hit_count;
	ulong compresses;
	uint64_t kvbase;
	ulong *debug;
	uint32_t cpu_devices;
	struct register_set *registers;
	uint64_t iohole;
};

#define TMPFILE              (0x2)
#define MAPFILE              (0x4)
#define MAPFILE_FOUND        (0x8)
#define MAPFILE_APPENDED    (0x10)
#define NO_PHYS_BASE        (0x20)
#define KVMHOST_32          (0x40)
#define KVMHOST_64          (0x80)
#define REGS_FROM_DUMPFILE (0x100)
#define REGS_FROM_MAPFILE  (0x200)
#define REGS_NOT_AVAIL     (0x400)

extern struct kvmdump_data *kvm;

#undef dprintf
#define dprintf(x...)   do { if (*(kvm->debug)) fprintf(kvm->ofp, x); } while (0)

int store_mapfile_offset(uint64_t, off_t *);
int load_mapfile_offset(uint64_t, off_t *);

struct qemu_device_x86;
int kvmdump_regs_store(uint32_t, struct qemu_device_x86 *);
#define KVMDUMP_REGS_START   (NR_CPUS+1)
#define KVMDUMP_REGS_END     (NR_CPUS+2)

#define UPPER_32_BITS    (0xffffffff00000000ULL)

enum CPU_REG {
	R_EAX,
	R_ECX,
	R_EDX,
	R_EBX,
	R_ESP,
	R_EBP,
	R_ESI,
	R_EDI,
	R_GP_MAX,
};