crash/kvmdump.h
Kazuhito Hagio f37df7df8a Fix gcc-11 compiler warning on kvmdump.c
Without the patch, the following gcc-11 compiler warning is emitted for
kvmdump.c:

In function 'write_mapfile_registers',
    inlined from 'write_mapfile_trailer' at kvmdump.c:947:3,
    inlined from 'kvmdump_init' at kvmdump.c:145:4:
kvmdump.c:972:13: warning: 'write' reading 8 bytes from a region of size 4 [-Wstringop-overread]
  972 |         if (write(kvm->mapfd, &kvm->cpu_devices, sizeof(uint64_t)) != sizeof(uint64_t))
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from kvmdump.c:19:
kvmdump.c: In function 'kvmdump_init':
kvmdump.h:67:18: note: source object 'cpu_devices' of size 4
   67 |         uint32_t cpu_devices;
      |                  ^~~~~~~~~~~
In file included from defs.h:26,
                 from kvmdump.c:18:
/usr/include/unistd.h:378:16: note: in a call to function 'write' declared with attribute 'access (read_only, 2, 3)'
  378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
      |                ^~~~~

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
2022-07-27 13:55:05 +09:00

110 lines
2.5 KiB
C

/*
* 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;
uint64_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,
};